Skip to content

Commit a2f8dfb

Browse files
authored
Update JWTTest.php
1 parent aa60b99 commit a2f8dfb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/JWTTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,26 @@ public function testExpiredExceptionPayload()
130130
}
131131
}
132132

133+
public function testExpiredExceptionTimestamp()
134+
{
135+
$this->expectException(ExpiredException::class);
136+
137+
JWT::$timestamp = 98765;
138+
$payload = [
139+
'message' => 'abc',
140+
'exp' => 1234,
141+
];
142+
$encoded = JWT::encode($payload, 'my_key', 'HS256');
143+
144+
try {
145+
JWT::decode($encoded, new Key('my_key', 'HS256'));
146+
} catch (ExpiredException $e) {
147+
$exTimestamp = $e->getTimestamp();
148+
$this->assertSame(98765, $exTimestamp);
149+
throw $e;
150+
}
151+
}
152+
133153
public function testBeforeValidExceptionPayload()
134154
{
135155
$this->expectException(BeforeValidException::class);

0 commit comments

Comments
 (0)