@@ -36,8 +36,8 @@ public function testExpiredToken()
36
36
{
37
37
$ this ->expectException (ExpiredException::class);
38
38
$ payload = [
39
- " message " => " abc " ,
40
- " exp " => time () - 20 ]; // time in the past
39
+ ' message ' => ' abc ' ,
40
+ ' exp ' => time () - 20 ]; // time in the past
41
41
$ encoded = JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
42
42
JWT ::decode ($ encoded , new Key ('my_key ' , 'HS256 ' ));
43
43
}
@@ -46,7 +46,7 @@ public function testBeforeValidTokenWithNbf()
46
46
{
47
47
$ this ->expectException (BeforeValidException::class);
48
48
$ payload = [
49
- " message " => " abc " ,
49
+ ' message ' => ' abc ' ,
50
50
"nbf " => time () + 20 ]; // time in the future
51
51
$ encoded = JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
52
52
JWT ::decode ($ encoded , new Key ('my_key ' , 'HS256 ' ));
@@ -56,7 +56,7 @@ public function testBeforeValidTokenWithIat()
56
56
{
57
57
$ this ->expectException (BeforeValidException::class);
58
58
$ payload = [
59
- " message " => " abc " ,
59
+ ' message ' => ' abc ' ,
60
60
"iat " => time () + 20 ]; // time in the future
61
61
$ encoded = JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
62
62
JWT ::decode ($ encoded , new Key ('my_key ' , 'HS256 ' ));
@@ -65,8 +65,8 @@ public function testBeforeValidTokenWithIat()
65
65
public function testValidToken ()
66
66
{
67
67
$ payload = [
68
- " message " => " abc " ,
69
- " exp " => time () + JWT ::$ leeway + 20 ]; // time in the future
68
+ ' message ' => ' abc ' ,
69
+ ' exp ' => time () + JWT ::$ leeway + 20 ]; // time in the future
70
70
$ encoded = JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
71
71
$ decoded = JWT ::decode ($ encoded , new Key ('my_key ' , 'HS256 ' ));
72
72
$ this ->assertEquals ($ decoded ->message , 'abc ' );
@@ -76,8 +76,8 @@ public function testValidTokenWithLeeway()
76
76
{
77
77
JWT ::$ leeway = 60 ;
78
78
$ payload = [
79
- " message " => " abc " ,
80
- " exp " => time () - 20 ]; // time in the past
79
+ ' message ' => ' abc ' ,
80
+ ' exp ' => time () - 20 ]; // time in the past
81
81
$ encoded = JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
82
82
$ decoded = JWT ::decode ($ encoded , new Key ('my_key ' , 'HS256 ' ));
83
83
$ this ->assertEquals ($ decoded ->message , 'abc ' );
@@ -88,8 +88,8 @@ public function testExpiredTokenWithLeeway()
88
88
{
89
89
JWT ::$ leeway = 60 ;
90
90
$ payload = [
91
- " message " => " abc " ,
92
- " exp " => time () - 70 ]; // time far in the past
91
+ ' message ' => ' abc ' ,
92
+ ' exp ' => time () - 70 ]; // time far in the past
93
93
$ this ->expectException (ExpiredException::class);
94
94
$ encoded = JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
95
95
$ decoded = JWT ::decode ($ encoded , new Key ('my_key ' , 'HS256 ' ));
@@ -100,9 +100,9 @@ public function testExpiredTokenWithLeeway()
100
100
public function testValidTokenWithNbf ()
101
101
{
102
102
$ payload = [
103
- " message " => " abc " ,
103
+ ' message ' => ' abc ' ,
104
104
"iat " => time (),
105
- " exp " => time () + 20 , // time in the future
105
+ ' exp ' => time () + 20 , // time in the future
106
106
"nbf " => time () - 20 ];
107
107
$ encoded = JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
108
108
$ decoded = JWT ::decode ($ encoded , new Key ('my_key ' , 'HS256 ' ));
@@ -113,7 +113,7 @@ public function testValidTokenWithNbfLeeway()
113
113
{
114
114
JWT ::$ leeway = 60 ;
115
115
$ payload = [
116
- " message " => " abc " ,
116
+ ' message ' => ' abc ' ,
117
117
"nbf " => time () + 20 ]; // not before in near (leeway) future
118
118
$ encoded = JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
119
119
$ decoded = JWT ::decode ($ encoded , new Key ('my_key ' , 'HS256 ' ));
@@ -125,7 +125,7 @@ public function testInvalidTokenWithNbfLeeway()
125
125
{
126
126
JWT ::$ leeway = 60 ;
127
127
$ payload = [
128
- " message " => " abc " ,
128
+ ' message ' => ' abc ' ,
129
129
"nbf " => time () + 65 ]; // not before too far in future
130
130
$ encoded = JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
131
131
$ this ->expectException (BeforeValidException::class);
@@ -137,7 +137,7 @@ public function testValidTokenWithIatLeeway()
137
137
{
138
138
JWT ::$ leeway = 60 ;
139
139
$ payload = [
140
- " message " => " abc " ,
140
+ ' message ' => ' abc ' ,
141
141
"iat " => time () + 20 ]; // issued in near (leeway) future
142
142
$ encoded = JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
143
143
$ decoded = JWT ::decode ($ encoded , new Key ('my_key ' , 'HS256 ' ));
@@ -149,7 +149,7 @@ public function testInvalidTokenWithIatLeeway()
149
149
{
150
150
JWT ::$ leeway = 60 ;
151
151
$ payload = [
152
- " message " => " abc " ,
152
+ ' message ' => ' abc ' ,
153
153
"iat " => time () + 65 ]; // issued too far in future
154
154
$ encoded = JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
155
155
$ this ->expectException (BeforeValidException::class);
@@ -160,8 +160,8 @@ public function testInvalidTokenWithIatLeeway()
160
160
public function testInvalidToken ()
161
161
{
162
162
$ payload = [
163
- " message " => " abc " ,
164
- " exp " => time () + 20 ]; // time in the future
163
+ ' message ' => ' abc ' ,
164
+ ' exp ' => time () + 20 ]; // time in the future
165
165
$ encoded = JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
166
166
$ this ->expectException (SignatureInvalidException::class);
167
167
JWT ::decode ($ encoded , new Key ('my_key2 ' , 'HS256 ' ));
@@ -170,8 +170,8 @@ public function testInvalidToken()
170
170
public function testNullKeyFails ()
171
171
{
172
172
$ payload = [
173
- " message " => " abc " ,
174
- " exp " => time () + JWT ::$ leeway + 20 ]; // time in the future
173
+ ' message ' => ' abc ' ,
174
+ ' exp ' => time () + JWT ::$ leeway + 20 ]; // time in the future
175
175
$ encoded = JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
176
176
$ this ->expectException (TypeError::class);
177
177
JWT ::decode ($ encoded , new Key (null , 'HS256 ' ));
@@ -180,8 +180,8 @@ public function testNullKeyFails()
180
180
public function testEmptyKeyFails ()
181
181
{
182
182
$ payload = [
183
- " message " => " abc " ,
184
- " exp " => time () + JWT ::$ leeway + 20 ]; // time in the future
183
+ ' message ' => ' abc ' ,
184
+ ' exp ' => time () + JWT ::$ leeway + 20 ]; // time in the future
185
185
$ encoded = JWT ::encode ($ payload , 'my_key ' , 'HS256 ' );
186
186
$ this ->expectException (InvalidArgumentException::class);
187
187
JWT ::decode ($ encoded , new Key ('' , 'HS256 ' ));
0 commit comments