Skip to content

Commit 121e6da

Browse files
committed
test: reset time properly
1 parent 3849f9c commit 121e6da

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

tests/Authentication/HasAccessTokensTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ protected function setUp(): void
3535
$this->db->table($this->tables['identities'])->truncate();
3636
}
3737

38+
protected function tearDown(): void
39+
{
40+
parent::tearDown();
41+
42+
// Reset the current time.
43+
Time::setTestNow();
44+
}
45+
3846
public function testGenerateToken(): void
3947
{
4048
$token = $this->user->generateAccessToken('foo');
@@ -213,8 +221,6 @@ public function testTokenTimeToExpired(): void
213221
$this->user->setAccessToken($token);
214222

215223
$this->assertSame('in 1 year', $this->user->currentAccessToken()->expires->humanize());
216-
217-
Time::setTestNow();
218224
}
219225

220226
/**

tests/Authentication/HasHmacTokensTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ protected function setUp(): void
3535
$this->db->table($this->tables['identities'])->truncate();
3636
}
3737

38+
protected function tearDown(): void
39+
{
40+
parent::tearDown();
41+
42+
// Reset the current time.
43+
Time::setTestNow();
44+
}
45+
3846
public function testGenerateHmacToken(): void
3947
{
4048
$token = $this->user->generateHmacToken('foo');
@@ -222,8 +230,6 @@ public function testHmacTokenTimeToExpired(): void
222230
$token = $this->user->generateHmacToken('foo', ['foo.bar'], $tokenExpiration);
223231

224232
$this->assertSame('in 1 year', $token->expires->humanize());
225-
226-
Time::setTestNow();
227233
}
228234

229235
/**

0 commit comments

Comments
 (0)