diff --git a/tests/Authentication/HasAccessTokensTest.php b/tests/Authentication/HasAccessTokensTest.php index d864860c0..0ca609f70 100644 --- a/tests/Authentication/HasAccessTokensTest.php +++ b/tests/Authentication/HasAccessTokensTest.php @@ -35,6 +35,14 @@ protected function setUp(): void $this->db->table($this->tables['identities'])->truncate(); } + protected function tearDown(): void + { + parent::tearDown(); + + // Reset the current time. + Time::setTestNow(); + } + public function testGenerateToken(): void { $token = $this->user->generateAccessToken('foo'); @@ -205,6 +213,8 @@ public function testIsTokenExpired(): void */ public function testTokenTimeToExpired(): void { + Time::setTestNow('2025-07-16 12:00:00'); + $tokenExpiration = Time::now()->addYears(1); $token = $this->user->generateAccessToken('foo', ['foo.bar'], $tokenExpiration); diff --git a/tests/Authentication/HasHmacTokensTest.php b/tests/Authentication/HasHmacTokensTest.php index 33909c1de..b7a64ff24 100644 --- a/tests/Authentication/HasHmacTokensTest.php +++ b/tests/Authentication/HasHmacTokensTest.php @@ -35,6 +35,14 @@ protected function setUp(): void $this->db->table($this->tables['identities'])->truncate(); } + protected function tearDown(): void + { + parent::tearDown(); + + // Reset the current time. + Time::setTestNow(); + } + public function testGenerateHmacToken(): void { $token = $this->user->generateHmacToken('foo'); @@ -214,6 +222,8 @@ public function testIsHmacTokenExpired(): void */ public function testHmacTokenTimeToExpired(): void { + Time::setTestNow('2025-07-16 12:00:00'); + $tokenExpiration = Time::now(); $tokenExpiration = $tokenExpiration->addYears(1);