blob: 67f41da8d99972a458460c5aa68c0c1ec673d0d0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
<?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
{
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();
}
}
|