@@ -22,9 +22,9 @@ public function test_decode_encoded_token($key, $algo, $age, $leeway, array $pay
2222 $ jwt = new JWT ($ key , $ algo , $ age , $ leeway );
2323 $ token = $ jwt ->encode ($ payload , $ header );
2424
25- $ this ->assertInternalType ( ' string ' , $ token );
25+ $ this ->assertIsString ( $ token );
2626 $ decoded = $ jwt ->decode ($ token );
27- $ this ->assertInternalType ( ' array ' , $ decoded );
27+ $ this ->assertIsArray ( $ decoded );
2828
2929 // Normalize.
3030 if (!isset ($ payload ['exp ' ])) {
@@ -34,11 +34,10 @@ public function test_decode_encoded_token($key, $algo, $age, $leeway, array $pay
3434 $ this ->assertSame ($ payload , $ decoded );
3535 }
3636
37- /**
38- * @expectedException \Ahc\Jwt\JWTException
39- */
4037 public function test_json_fail ()
4138 {
39+ $ this ->expectException (\Ahc \Jwt \JWTException::class);
40+
4241 $ jwt = new JWT ('very^secre7 ' );
4342
4443 try {
@@ -52,10 +51,11 @@ public function test_json_fail()
5251
5352 /**
5453 * @dataProvider data2
55- * @expectedException \Ahc\Jwt\JWTException
5654 */
5755 public function test_decode_fail ($ key , $ algo , $ age , $ leeway , $ offset , $ error , $ token )
5856 {
57+ $ this ->expectException (\Ahc \Jwt \JWTException::class);
58+
5959 $ jwt = new JWT ($ key , $ algo , $ age , $ leeway );
6060 $ token = is_string ($ token ) ? $ token : $ jwt ->encode ($ token );
6161
@@ -79,9 +79,9 @@ public function test_rs_decode_encoded($key, $algo, $age, $leeway, array $payloa
7979 $ jwt = new JWT ($ key , str_replace ('HS ' , 'RS ' , $ algo ), $ age , $ leeway );
8080 $ token = $ jwt ->encode ($ payload , $ header );
8181
82- $ this ->assertInternalType ( ' string ' , $ token );
82+ $ this ->assertIsString ( $ token );
8383 $ decoded = $ jwt ->decode ($ token );
84- $ this ->assertInternalType ( ' array ' , $ decoded );
84+ $ this ->assertIsArray ( $ decoded );
8585
8686 // Normalize.
8787 if (!isset ($ payload ['exp ' ])) {
@@ -93,10 +93,11 @@ public function test_rs_decode_encoded($key, $algo, $age, $leeway, array $payloa
9393
9494 /**
9595 * @dataProvider data3
96- * @expectedException \Ahc\Jwt\JWTException
9796 */
9897 public function test_rs_invalid_key ($ method , $ key , $ arg )
9998 {
99+ $ this ->expectException (\Ahc \Jwt \JWTException::class);
100+
100101 $ jwt = new JWT ($ key , 'RS256 ' );
101102
102103 try {
@@ -121,12 +122,11 @@ public function test_kid()
121122 return $ jwt ;
122123 }
123124
124- /**
125- * @expectedException \Ahc\Jwt\JWTException
126- * @expectedExceptionMessage Invalid token: Unknown key ID
127- */
128125 public function test_kid_invalid ()
129126 {
127+ $ this ->expectException (\Ahc \Jwt \JWTException::class);
128+ $ this ->expectExceptionMessage ('Invalid token: Unknown key ID ' );
129+
130130 // keys can be sent as array too
131131 $ jwt = new JWT (['key1 ' => 'secret1 ' , 'key2 ' => 'secret2 ' ], 'HS256 ' );
132132
0 commit comments