diff options
author | Peter Zhang <peter@innocraft.com> | 2022-01-05 00:43:34 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-05 00:43:34 +0300 |
commit | 647fe105037de7813f785fc30b8b63717aaa465c (patch) | |
tree | 36cd9a9392dcb208bed818420bbc606016c17a85 /plugins/UsersManager | |
parent | dbe43bb82e8897bb048a19f38c1f15d6858300c2 (diff) |
Update test_deleteExpiredTokens (#18568)
fix the date on tests
Diffstat (limited to 'plugins/UsersManager')
-rw-r--r-- | plugins/UsersManager/tests/Integration/ModelTest.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/plugins/UsersManager/tests/Integration/ModelTest.php b/plugins/UsersManager/tests/Integration/ModelTest.php index 399080e301..c19e974b9a 100644 --- a/plugins/UsersManager/tests/Integration/ModelTest.php +++ b/plugins/UsersManager/tests/Integration/ModelTest.php @@ -12,6 +12,7 @@ use Piwik\Access\Role\View; use Piwik\Access\Role\Write; use Piwik\Auth\Password; use Piwik\Common; +use Piwik\Date; use Piwik\Db; use Piwik\Option; use Piwik\Piwik; @@ -355,15 +356,19 @@ class ModelTest extends IntegrationTestCase public function test_deleteExpiredTokens() { - $id1 = $this->model->addTokenAuth($this->login, 'token', 'MyDescription1', '2020-01-01 03:04:05', '2020-01-02 03:04:05'); + $date = Date::factory('now')->addMonth(1)->getDatetime(); + $dateNotExpired = Date::factory('now')->addMonth(24)->getDatetime(); + $dateExpired = Date::factory('now')->subMonth(1)->getDatetime(); + + $id1 = $this->model->addTokenAuth($this->login, 'token', 'MyDescription1', '2020-01-01 03:04:05', $dateExpired); $id2 = $this->model->addTokenAuth($this->login, 'token2', 'MyDescription2', '2020-01-02 03:04:05'); - $id3 = $this->model->addTokenAuth($this->login, 'token3', 'MyDescription3', '2020-01-03 03:04:05', '2022-01-02 03:04:05'); - $id4 = $this->model->addTokenAuth($this->login2, 'token4', 'MyDescription4', '2020-01-04 03:04:05', '2024-01-02 03:04:05'); + $id3 = $this->model->addTokenAuth($this->login, 'token3', 'MyDescription3', '2020-01-03 03:04:05', $dateNotExpired); + $id4 = $this->model->addTokenAuth($this->login2, 'token4', 'MyDescription4', '2020-01-04 03:04:05', $dateNotExpired); $id5 = $this->model->addTokenAuth($this->login2, 'token5', 'MyDescription5', '2020-01-05 03:04:05'); $id6 = $this->model->addTokenAuth($this->login2, 'token6', 'MyDescription6', '2020-01-06 03:04:05', '2018-01-02 03:04:05'); // id1 and id6 are expired and should have been deleted - $this->model->deleteExpiredTokens('2021-01-02 03:04:05'); + $this->model->deleteExpiredTokens($date); $tokens = $this->model->getAllNonSystemTokensForLogin($this->login); $this->assertEquals($id2, $tokens[0]['idusertokenauth']); |