diff options
author | Peter Zhang <peter@innocraft.com> | 2021-11-13 02:49:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-13 02:49:08 +0300 |
commit | bf341b7c0ba46691bf3e475ebaa58391363cd7ec (patch) | |
tree | 232d4a0ec7aa3b8c801592872eb2d2523dc66f0e /plugins/Feedback/tests/Integration | |
parent | 9c58f4e71db9133b2c83d51cf700e818ec5ff7e4 (diff) |
add feedback question, remove other related. (#18262)
* remove feedback links
remove feedback links
* update screen shot
update screen shot
* add feedback question
add feedback question
* update close to icon
update close to icon
* built vue files
* remove in line css
remove in line css, change to less file
* move translation key to plugin
move translation key to plugin
* remove feedback popup
remove feedback popup
* update remove some test and feedback related
update remove some test and feedback related
* add draft tests
add draft tests
* update feedback add php and UI tests
update feedback add php and UI tests
* update test screen shots
update test screen shots
* Update demo.twig
add heart to demo page
* add feedback back in extend the modal
add feedback back in extend the modal
* update coreHome
update coreHome
* update screen shots
update screen shots
* Update FeedbackQuestion_spec.js
update js tests
* update test
update test
* built vue files
* update screenshot and js tests
update screenshot and js tests
* Update FeedbackQuestion_spec.js
test success
* update screenshot
update screenshot
* update tests
update tests
* fix test error
fix test error
* Removing the refer us popup
* Readding accidentally removed language files
* update test
* update test
* remove refer us
* update feedback umd js
update feedback umd js
* merge Andy branch
merge Andy branch and update screen shots
* revert language changes
revert language changes
* revert language changes
revert language changes
* revert language file
revert language file
* revert unrelated lang change
revert unrelated lang change
* revert lang change
revert lang change
* revert lang change
revert lang change
* Delete ControllerTest.php
remove controller test not in used
* Update core/Piwik.php
Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com>
* Update plugins/Morpheus/javascripts/piwikHelper.js
Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com>
* update a big that cancel and reopen it again
update a bug that cancel and reopen it again
* update compare error
update compare error
* Update plugins/Feedback/FeedbackReminder.php
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* update feedback show logic
update feedback show logic
* Update FeedbackQuestion_spec.js
update tests
* Update Feedback.php
remove comments
* Update .gitignore
* update vue build file
update vue build file
* built vue files
* update vue build file
update vue build file
* add close button
add close button
* add close button
add close button
* update screenshot
update screenshot
* remove umd
remove umd
* git add corehome
git add corehome
* revert all the umd file
revert all the umd file
* built vue files
* built vue files
* Update plugins/Feedback/lang/en.json
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* update per review
update per review
* built vue files
* set auto focus on modal open
set auto focus on modal open
* built vue files
* Update FeedbackQuestion.vue
add please write in english
* built vue files
* remove please write in English
remove please write in English
* built vue files
* update tests and question tests
update tests and question tests
* set cookie in the test
set cookie in the test
* Update page-renderer.js
add setCookie to tests
* update test only load 1
update test only load 1
* built vue files
* Update FeedbackQuestion_feedback_popup.png
update screen shot
* Update piwikHelper.js
update button css
* update screen shot
update screen shot
* Update plugins/Feedback/Feedback.php
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* Update plugins/Feedback/vue/src/FeedbackQuestion/FeedbackQuestion.vue
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* Update plugins/Feedback/API.php
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* Update plugins/Feedback/API.php
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* Update core/Plugin/API.php
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* update cookie and tests
update cookie and tests
* built vue files
* test setcookie in tests
test setcookie in tests
* update tests
update tests
* update tests
update tests
* Update FeedbackQuestion_spec.js
update cookie test
* extend setCookie in test
extend setCookie in test
* update elints format
update elints format
* built vue files
* test set cookie
test set cookie
* built vue files
* Update FeedbackQuestion_spec.js
set cookie after goto URL
* Update FeedbackQuestion_spec.js
int to string
* update set cookie
update set cookie
* update test URL
update test URL
Co-authored-by: peterhashair <peterhashair@users.noreply.github.com>
Co-authored-by: Andrew Davis <andrew.affinity@gmail.com>
Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com>
Co-authored-by: Stefan Giehl <stefan@matomo.org>
Diffstat (limited to 'plugins/Feedback/tests/Integration')
-rw-r--r-- | plugins/Feedback/tests/Integration/ControllerTest.php | 116 | ||||
-rw-r--r-- | plugins/Feedback/tests/Integration/FeedbackTest.php | 41 | ||||
-rw-r--r-- | plugins/Feedback/tests/Integration/ReferBannerTest.php | 119 |
3 files changed, 25 insertions, 251 deletions
diff --git a/plugins/Feedback/tests/Integration/ControllerTest.php b/plugins/Feedback/tests/Integration/ControllerTest.php deleted file mode 100644 index a1699cf2bd..0000000000 --- a/plugins/Feedback/tests/Integration/ControllerTest.php +++ /dev/null @@ -1,116 +0,0 @@ -<?php -/** - * Matomo - free/libre analytics platform - * - * @link http://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ - -namespace Piwik\Plugins\Feedback\tests\Integration; - -use Piwik\Date; -use Piwik\NoAccessException; -use Piwik\Option; -use Piwik\Plugins\Feedback\Controller; -use Piwik\Plugins\UsersManager\Model; -use Piwik\Tests\Framework\Mock\FakeAccess; -use Piwik\Tests\Framework\TestCase\IntegrationTestCase; - -class ControllerTest extends IntegrationTestCase -{ - /** @var Controller */ - private $controller; - - /** @var Model */ - private $userModel; - - private $now; - - public function setUp(): void - { - parent::setUp(); - $this->controller = new Controller(); - - $this->userModel = new Model(); - $this->userModel->addUser( - 'user1', - 'a98732d98732', - 'user1@example.com', - '2019-03-03' - ); - FakeAccess::$identity = 'user1'; - FakeAccess::$superUser = false; - - $this->now = Date::$now; - Date::$now = Date::factory('2019-05-31')->getTimestamp(); - } - - public function tearDown(): void - { - FakeAccess::$identity = 'user1'; - Option::deleteLike('Feedback.nextFeedbackReminder.%'); - $this->userModel->deleteUserOnly('user1'); - Date::$now = $this->now; - - parent::tearDown(); - } - - public function provideContainerConfig() - { - return array( - 'Piwik\Access' => new FakeAccess() - ); - } - - public function test_updateFeedbackReminder_addNinetyDays() - { - $_POST['nextReminder'] = '90'; - $this->controller->updateFeedbackReminderDate(); - - $option = Option::get('Feedback.nextFeedbackReminder.user1'); - $this->assertEquals($option, '2019-08-29'); - } - - public function test_updateFeedbackReminder_neverAgain() - { - $_POST['nextReminder'] = '-1'; - $this->controller->updateFeedbackReminderDate(); - - $option = Option::get('Feedback.nextFeedbackReminder.user1'); - $this->assertEquals($option, '-1'); - } - - public function test_updateFeedbackReminder_notLoggedIn() - { - $this->expectException(NoAccessException::class); - FakeAccess::$identity = null; - FakeAccess::$superUser = false; - $this->controller->updateFeedbackReminderDate(); - } - - public function test_updateReferReminder_add180Days() - { - $_POST['nextReminder'] = '180'; - $this->controller->updateReferReminderDate(); - - $option = Option::get('Feedback.nextReferReminder.user1'); - $this->assertEquals($option, '2019-11-27'); - } - - public function test_updateReferReminder_neverAgain() - { - $_POST['nextReminder'] = '-1'; - $this->controller->updateReferReminderDate(); - - $option = Option::get('Feedback.nextReferReminder.user1'); - $this->assertEquals($option, '-1'); - } - - public function test_updateReferReminder_notLoggedIn() - { - $this->expectException(NoAccessException::class); - FakeAccess::$identity = null; - FakeAccess::$superUser = false; - $this->controller->updateReferReminderDate(); - } -} diff --git a/plugins/Feedback/tests/Integration/FeedbackTest.php b/plugins/Feedback/tests/Integration/FeedbackTest.php index f55d6e20f2..66fa6e7525 100644 --- a/plugins/Feedback/tests/Integration/FeedbackTest.php +++ b/plugins/Feedback/tests/Integration/FeedbackTest.php @@ -9,8 +9,10 @@ namespace Piwik\Plugins\Feedback\tests\Unit; +use CpChart\Chart\Data; use Piwik\Date; use Piwik\Option; +use Piwik\Piwik; use Piwik\Plugins\Feedback\Feedback; use Piwik\Plugins\UsersManager\Model; use Piwik\Tests\Framework\Mock\FakeAccess; @@ -40,9 +42,16 @@ class FeedbackTest extends IntegrationTestCase 'user1@example.com', '2019-03-03' ); + + $this->userModel->addUser( + 'user2', + 'a98732d98732', + 'user2@example.com', + Date('Y-m-d') + ); FakeAccess::$identity = 'user1'; FakeAccess::$superUser = false; - + FakeAccess::$idSitesView = [1]; $this->now = Date::$now; } @@ -51,8 +60,12 @@ class FeedbackTest extends IntegrationTestCase FakeAccess::$identity = 'user1'; Option::deleteLike('Feedback.nextFeedbackReminder.%'); $this->userModel->deleteUserOnly('user1'); - Date::$now = $this->now; + FakeAccess::$identity = 'user2'; + Option::deleteLike('Feedback.nextFeedbackReminder.%'); + $this->userModel->deleteUserOnly('user2'); + + Date::$now = $this->now; parent::tearDown(); } @@ -71,12 +84,6 @@ class FeedbackTest extends IntegrationTestCase $this->assertFalse($this->feedback->getShouldPromptForFeedback()); } - public function test_shouldPromptForFeedback_noFeedbackReminderOptionForUser() - { - Date::$now = Date::factory('2019-05-31')->getTimestamp(); // 89 days - - $this->assertFalse($this->feedback->getShouldPromptForFeedback()); - } public function test_shouldPromptForFeedback_dontRemindUserAgain() { @@ -87,25 +94,27 @@ class FeedbackTest extends IntegrationTestCase public function test_shouldPromptForFeedback_nextReminderDateInPast() { + FakeAccess::$identity = 'user1'; Option::set('Feedback.nextFeedbackReminder.user1', '2019-05-31'); - Date::$now = Date::factory('2019-06-01')->getTimestamp(); - $this->assertTrue($this->feedback->getShouldPromptForFeedback()); } public function test_shouldPromptForFeedack_nextReminderDateToday() { - Option::set('Feedback.nextFeedbackReminder.user1', '2019-05-31'); - Date::$now = Date::factory('2019-05-31')->getTimestamp(); - + Option::set('Feedback.nextFeedbackReminder.user1', '2018-10-31'); $this->assertTrue($this->feedback->getShouldPromptForFeedback()); } - public function test_shouldPromptForFeedack_nextReminderDateInFuture() + public function test_shouldPromptForFeedback_user_oldThanHalfYear() { - Option::set('Feedback.nextFeedbackReminder.user1', '2019-05-31'); - Date::$now = Date::factory('2019-05-30')->getTimestamp(); + FakeAccess::$identity = 'user1'; + Option::deleteLike('Feedback.nextFeedbackReminder.user1'); + $this->assertFalse($this->feedback->getShouldPromptForFeedback()); + } + public function test_shouldNotPromptForFeedback_user_LessThanHalfYear() + { + FakeAccess::$identity = 'user2'; $this->assertFalse($this->feedback->getShouldPromptForFeedback()); } } diff --git a/plugins/Feedback/tests/Integration/ReferBannerTest.php b/plugins/Feedback/tests/Integration/ReferBannerTest.php deleted file mode 100644 index b57377ee68..0000000000 --- a/plugins/Feedback/tests/Integration/ReferBannerTest.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php -/** - * Matomo - free/libre analytics platform - * - * @link http://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ - -namespace Piwik\Plugins\Feedback\tests\Integration; - -use Piwik\Date; -use Piwik\Option; -use Piwik\Plugins\Feedback\Feedback; -use Piwik\Plugins\UsersManager\Model; -use Piwik\Tests\Framework\Mock\FakeAccess; -use Piwik\Tests\Framework\TestCase\IntegrationTestCase; - -class ReferBannerTest extends IntegrationTestCase -{ - /** @var Feedback */ - private $feedback; - - /** @var Model */ - private $userModel; - - public function setUp(): void - { - parent::setUp(); - - $this->feedback = $this->createPartialMock(Feedback::class, ['isDisabledInTestMode']); - $this->feedback->method('isDisabledInTestMode')->willReturn(false); - - $this->userModel = new Model(); - $this->userModel->addUser( - 'user1', - 'a98732d98732', - 'user1@example.com', - '2019-03-03', - 'super' - ); - FakeAccess::$identity = 'user1'; - FakeAccess::$superUser = false; - } - - public function tearDown(): void - { - Option::deleteLike('Feedback.nextReferReminder.%'); - try { - $this->userModel->deleteUserOnly('user1'); - } catch (\Exception $e) { - // ignore possible errors triggered when the delete user event is posted - } - - parent::tearDown(); - } - - public function provideContainerConfig() - { - return array( - 'Piwik\Access' => new FakeAccess() - ); - } - - - public function test_shouldNotShowReferBannerTo_AnonymousUser() - { - FakeAccess::$identity = ''; - - $this->assertFalse($this->feedback->showReferBanner()); - } - - public function test_shouldNotShowReferBannerTo_NotSuperUser() - { - FakeAccess::$identity = 'user1'; - - $this->assertFalse($this->feedback->showReferBanner()); - } - - public function test_shouldNotShowReferBannerTo_SuperUser_First() - { - FakeAccess::$identity = 'super'; - FakeAccess::$superUser = true; - - $this->assertFalse($this->feedback->showReferBanner()); - } - - public function test_shouldNotShowReferBanner_ifNeverRemindOn() - { - FakeAccess::$identity = 'super'; - FakeAccess::$superUser = true; - Option::set('Feedback.nextReferReminder.super', '-1'); - - $this->assertFalse($this->feedback->showReferBanner()); - } - - public function test_shouldNotShowReferBanner_ifNextReminderDateInTheFuture() - { - FakeAccess::$identity = 'super'; - FakeAccess::$superUser = true; - - Date::$now = strtotime('2021-01-01'); - $futureDate = Date::factory('2021-02-01')->toString('Y-m-d'); - Option::set('Feedback.nextReferReminder.super', $futureDate); - - $this->assertFalse($this->feedback->showReferBanner()); - } - - public function test_shouldShowReferBanner_ifNextReminderDateInThePast() - { - FakeAccess::$identity = 'super'; - FakeAccess::$superUser = true; - - Date::$now = strtotime('2021-01-01'); - $pastDate = Date::factory('2020-01-01')->toString('Y-m-d'); - Option::set('Feedback.nextReferReminder.super', $pastDate); - - $this->assertTrue($this->feedback->showReferBanner()); - } -} |