@@ -31,19 +31,19 @@ public function testUrlSafeCharacters()
31
31
32
32
public function testMalformedUtf8StringsFail ()
33
33
{
34
- $ this ->setExpectedException ('DomainException ' );
34
+ $ this ->expectException ('DomainException ' );
35
35
JWT ::encode (pack ('c ' , 128 ), 'a ' );
36
36
}
37
37
38
38
public function testMalformedJsonThrowsException ()
39
39
{
40
- $ this ->setExpectedException ('DomainException ' );
40
+ $ this ->expectException ('DomainException ' );
41
41
JWT ::jsonDecode ('this is not valid JSON string ' );
42
42
}
43
43
44
44
public function testExpiredToken ()
45
45
{
46
- $ this ->setExpectedException ('Firebase\JWT\ExpiredException ' );
46
+ $ this ->expectException ('Firebase\JWT\ExpiredException ' );
47
47
$ payload = array (
48
48
"message " => "abc " ,
49
49
"exp " => time () - 20 ); // time in the past
@@ -53,7 +53,7 @@ public function testExpiredToken()
53
53
54
54
public function testBeforeValidTokenWithNbf ()
55
55
{
56
- $ this ->setExpectedException ('Firebase\JWT\BeforeValidException ' );
56
+ $ this ->expectException ('Firebase\JWT\BeforeValidException ' );
57
57
$ payload = array (
58
58
"message " => "abc " ,
59
59
"nbf " => time () + 20 ); // time in the future
@@ -63,7 +63,7 @@ public function testBeforeValidTokenWithNbf()
63
63
64
64
public function testBeforeValidTokenWithIat ()
65
65
{
66
- $ this ->setExpectedException ('Firebase\JWT\BeforeValidException ' );
66
+ $ this ->expectException ('Firebase\JWT\BeforeValidException ' );
67
67
$ payload = array (
68
68
"message " => "abc " ,
69
69
"iat " => time () + 20 ); // time in the future
@@ -99,7 +99,7 @@ public function testExpiredTokenWithLeeway()
99
99
$ payload = array (
100
100
"message " => "abc " ,
101
101
"exp " => time () - 70 ); // time far in the past
102
- $ this ->setExpectedException ('Firebase\JWT\ExpiredException ' );
102
+ $ this ->expectException ('Firebase\JWT\ExpiredException ' );
103
103
$ encoded = JWT ::encode ($ payload , 'my_key ' );
104
104
$ decoded = JWT ::decode ($ encoded , 'my_key ' , array ('HS256 ' ));
105
105
$ this ->assertEquals ($ decoded ->message , 'abc ' );
@@ -147,7 +147,7 @@ public function testInvalidTokenWithNbfLeeway()
147
147
"message " => "abc " ,
148
148
"nbf " => time () + 65 ); // not before too far in future
149
149
$ encoded = JWT ::encode ($ payload , 'my_key ' );
150
- $ this ->setExpectedException ('Firebase\JWT\BeforeValidException ' );
150
+ $ this ->expectException ('Firebase\JWT\BeforeValidException ' );
151
151
$ decoded = JWT ::decode ($ encoded , 'my_key ' , array ('HS256 ' ));
152
152
JWT ::$ leeway = 0 ;
153
153
}
@@ -171,7 +171,7 @@ public function testInvalidTokenWithIatLeeway()
171
171
"message " => "abc " ,
172
172
"iat " => time () + 65 ); // issued too far in future
173
173
$ encoded = JWT ::encode ($ payload , 'my_key ' );
174
- $ this ->setExpectedException ('Firebase\JWT\BeforeValidException ' );
174
+ $ this ->expectException ('Firebase\JWT\BeforeValidException ' );
175
175
$ decoded = JWT ::decode ($ encoded , 'my_key ' , array ('HS256 ' ));
176
176
JWT ::$ leeway = 0 ;
177
177
}
@@ -182,7 +182,7 @@ public function testInvalidToken()
182
182
"message " => "abc " ,
183
183
"exp " => time () + 20 ); // time in the future
184
184
$ encoded = JWT ::encode ($ payload , 'my_key ' );
185
- $ this ->setExpectedException ('Firebase\JWT\SignatureInvalidException ' );
185
+ $ this ->expectException ('Firebase\JWT\SignatureInvalidException ' );
186
186
$ decoded = JWT ::decode ($ encoded , 'my_key2 ' , array ('HS256 ' ));
187
187
}
188
188
@@ -192,7 +192,7 @@ public function testNullKeyFails()
192
192
"message " => "abc " ,
193
193
"exp " => time () + JWT ::$ leeway + 20 ); // time in the future
194
194
$ encoded = JWT ::encode ($ payload , 'my_key ' );
195
- $ this ->setExpectedException ('InvalidArgumentException ' );
195
+ $ this ->expectException ('InvalidArgumentException ' );
196
196
$ decoded = JWT ::decode ($ encoded , null , array ('HS256 ' ));
197
197
}
198
198
@@ -202,7 +202,7 @@ public function testEmptyKeyFails()
202
202
"message " => "abc " ,
203
203
"exp " => time () + JWT ::$ leeway + 20 ); // time in the future
204
204
$ encoded = JWT ::encode ($ payload , 'my_key ' );
205
- $ this ->setExpectedException ('InvalidArgumentException ' );
205
+ $ this ->expectException ('InvalidArgumentException ' );
206
206
$ decoded = JWT ::decode ($ encoded , '' , array ('HS256 ' ));
207
207
}
208
208
@@ -237,21 +237,21 @@ public function testArrayAccessKIDChooser()
237
237
public function testNoneAlgorithm ()
238
238
{
239
239
$ msg = JWT ::encode ('abc ' , 'my_key ' );
240
- $ this ->setExpectedException ('UnexpectedValueException ' );
240
+ $ this ->expectException ('UnexpectedValueException ' );
241
241
JWT ::decode ($ msg , 'my_key ' , array ('none ' ));
242
242
}
243
243
244
244
public function testIncorrectAlgorithm ()
245
245
{
246
246
$ msg = JWT ::encode ('abc ' , 'my_key ' );
247
- $ this ->setExpectedException ('UnexpectedValueException ' );
247
+ $ this ->expectException ('UnexpectedValueException ' );
248
248
JWT ::decode ($ msg , 'my_key ' , array ('RS256 ' ));
249
249
}
250
250
251
251
public function testMissingAlgorithm ()
252
252
{
253
253
$ msg = JWT ::encode ('abc ' , 'my_key ' );
254
- $ this ->setExpectedException ('UnexpectedValueException ' );
254
+ $ this ->expectException ('UnexpectedValueException ' );
255
255
JWT ::decode ($ msg , 'my_key ' );
256
256
}
257
257
@@ -263,20 +263,20 @@ public function testAdditionalHeaders()
263
263
264
264
public function testInvalidSegmentCount ()
265
265
{
266
- $ this ->setExpectedException ('UnexpectedValueException ' );
266
+ $ this ->expectException ('UnexpectedValueException ' );
267
267
JWT ::decode ('brokenheader.brokenbody ' , 'my_key ' , array ('HS256 ' ));
268
268
}
269
269
270
270
public function testInvalidSignatureEncoding ()
271
271
{
272
272
$ msg = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwibmFtZSI6ImZvbyJ9.Q4Kee9E8o0Xfo4ADXvYA8t7dN_X_bU9K5w6tXuiSjlUxx " ;
273
- $ this ->setExpectedException ('UnexpectedValueException ' );
273
+ $ this ->expectException ('UnexpectedValueException ' );
274
274
JWT ::decode ($ msg , 'secret ' , array ('HS256 ' ));
275
275
}
276
276
277
277
public function testVerifyError ()
278
278
{
279
- $ this ->setExpectedException ('DomainException ' );
279
+ $ this ->expectException ('DomainException ' );
280
280
$ pkey = openssl_pkey_new ();
281
281
$ msg = JWT ::encode ('abc ' , $ pkey , 'RS256 ' );
282
282
self ::$ opensslVerifyReturnValue = -1 ;
0 commit comments