File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,25 @@ function testMalformedJsonThrowsException() {
28
28
$ this ->setExpectedException ('DomainException ' );
29
29
JWT ::jsonDecode ('this is not valid JSON string ' );
30
30
}
31
+
32
+ function testExpiredToken (){
33
+ $ this ->setExpectedException ('UnexpectedValueException ' );
34
+ $ payload = array (
35
+ "message " => "abc " ,
36
+ "exp " => time ()-20 ); // time in the past
37
+ $ encoded = JWT ::encode ($ payload , 'my_key ' );
38
+ JWT ::decode ($ encoded );
39
+ }
40
+
41
+ function testValidToken (){
42
+ $ payload = array (
43
+ "message " => "abc " ,
44
+ "exp " => time ()+20 ); // time in the future
45
+ $ encoded = JWT ::encode ($ payload , 'my_key ' );
46
+ $ decoded = JWT ::decode ($ encoded , 'my_key ' );
47
+ $ this ->assertEquals ($ decoded ->message , 'abc ' );
48
+ }
49
+
31
50
}
32
51
33
52
?>
You can’t perform that action at this time.
0 commit comments