1313
1414use Illuminate \Http \Request ;
1515use Mockery ;
16- use stdClass ;
16+ use Mockery \ MockInterface ;
1717use PHPOpenSourceSaver \JWTAuth \Contracts \Providers \Auth ;
1818use PHPOpenSourceSaver \JWTAuth \Exceptions \JWTException ;
1919use PHPOpenSourceSaver \JWTAuth \Exceptions \TokenInvalidException ;
2424use PHPOpenSourceSaver \JWTAuth \Payload ;
2525use PHPOpenSourceSaver \JWTAuth \Test \Stubs \UserStub ;
2626use PHPOpenSourceSaver \JWTAuth \Token ;
27+ use stdClass ;
2728
2829class JWTAuthTest extends AbstractTestCase
2930{
3031 /**
31- * @var \Mockery\ MockInterface|\PHPOpenSourceSaver\JWTAuth\ Manager
32+ * @var MockInterface|Manager
3233 */
3334 protected $ manager ;
3435
3536 /**
36- * @var \Mockery\ MockInterface|\PHPOpenSourceSaver\JWTAuth\Contracts\Providers\ Auth
37+ * @var MockInterface|Auth
3738 */
3839 protected $ auth ;
3940
4041 /**
41- * @var \Mockery\ MockInterface|\PHPOpenSourceSaver\JWTAuth\Http\Parser\ Parser
42+ * @var MockInterface|Parser
4243 */
4344 protected $ parser ;
4445
4546 /**
46- * @var \PHPOpenSourceSaver\JWTAuth\ JWTAuth
47+ * @var JWTAuth
4748 */
4849 protected $ jwtAuth ;
4950
@@ -62,10 +63,10 @@ public function it_should_return_a_token_when_passing_a_user()
6263 $ payloadFactory ->shouldReceive ('make ' )->andReturn (Mockery::mock (Payload::class));
6364
6465 $ this ->manager
65- ->shouldReceive ('getPayloadFactory->customClaims ' )
66- ->once ()
67- ->with (['sub ' => 1 , 'prv ' => sha1 ('PHPOpenSourceSaver\JWTAuth\Test\Stubs\UserStub ' ), 'foo ' => 'bar ' , 'role ' => 'admin ' ])
68- ->andReturn ($ payloadFactory );
66+ ->shouldReceive ('getPayloadFactory->customClaims ' )
67+ ->once ()
68+ ->with (['sub ' => 1 , 'prv ' => sha1 ('PHPOpenSourceSaver\JWTAuth\Test\Stubs\UserStub ' ), 'foo ' => 'bar ' , 'role ' => 'admin ' ])
69+ ->andReturn ($ payloadFactory );
6970
7071 $ this ->manager ->shouldReceive ('encode->get ' )->once ()->andReturn ('foo.bar.baz ' );
7172
@@ -80,8 +81,8 @@ public function it_should_pass_provider_check_if_hash_matches()
8081 $ payloadFactory = Mockery::mock (Factory::class);
8182 $ payloadFactory ->shouldReceive ('make ' )->andReturn (Mockery::mock (Payload::class));
8283 $ payloadFactory ->shouldReceive ('get ' )
83- ->with ('prv ' )
84- ->andReturn (sha1 ('PHPOpenSourceSaver\JWTAuth\Test\Stubs\UserStub ' ));
84+ ->with ('prv ' )
85+ ->andReturn (sha1 ('PHPOpenSourceSaver\JWTAuth\Test\Stubs\UserStub ' ));
8586
8687 $ this ->manager ->shouldReceive ('decode ' )->once ()->andReturn ($ payloadFactory );
8788
@@ -94,8 +95,8 @@ public function it_should_pass_provider_check_if_hash_matches_when_provider_is_n
9495 $ payloadFactory = Mockery::mock (Factory::class);
9596 $ payloadFactory ->shouldReceive ('make ' )->andReturn (Mockery::mock (Payload::class));
9697 $ payloadFactory ->shouldReceive ('get ' )
97- ->with ('prv ' )
98- ->andReturnNull ();
98+ ->with ('prv ' )
99+ ->andReturnNull ();
99100
100101 $ this ->manager ->shouldReceive ('decode ' )->once ()->andReturn ($ payloadFactory );
101102
@@ -108,8 +109,8 @@ public function it_should_not_pass_provider_check_if_hash_not_match()
108109 $ payloadFactory = Mockery::mock (Factory::class);
109110 $ payloadFactory ->shouldReceive ('make ' )->andReturn (Mockery::mock (Payload::class));
110111 $ payloadFactory ->shouldReceive ('get ' )
111- ->with ('prv ' )
112- ->andReturn (sha1 ('PHPOpenSourceSaver\JWTAuth\Test\Stubs\UserStub1 ' ));
112+ ->with ('prv ' )
113+ ->andReturn (sha1 ('PHPOpenSourceSaver\JWTAuth\Test\Stubs\UserStub1 ' ));
113114
114115 $ this ->manager ->shouldReceive ('decode ' )->once ()->andReturn ($ payloadFactory );
115116
@@ -123,10 +124,10 @@ public function it_should_return_a_token_when_passing_valid_credentials_to_attem
123124 $ payloadFactory ->shouldReceive ('make ' )->andReturn (Mockery::mock (Payload::class));
124125
125126 $ this ->manager
126- ->shouldReceive ('getPayloadFactory->customClaims ' )
127- ->once ()
128- ->with (['sub ' => 1 , 'prv ' => sha1 ('PHPOpenSourceSaver\JWTAuth\Test\Stubs\UserStub ' ), 'foo ' => 'bar ' , 'role ' => 'admin ' ])
129- ->andReturn ($ payloadFactory );
127+ ->shouldReceive ('getPayloadFactory->customClaims ' )
128+ ->once ()
129+ ->with (['sub ' => 1 , 'prv ' => sha1 ('PHPOpenSourceSaver\JWTAuth\Test\Stubs\UserStub ' ), 'foo ' => 'bar ' , 'role ' => 'admin ' ])
130+ ->andReturn ($ payloadFactory );
130131
131132 $ this ->manager ->shouldReceive ('encode->get ' )->once ()->andReturn ('foo.bar.baz ' );
132133
@@ -168,7 +169,7 @@ public function it_should_return_the_owning_user_from_a_token_containing_an_exis
168169 $ this ->manager ->shouldReceive ('decode ' )->once ()->andReturn ($ payload );
169170
170171 $ this ->auth ->shouldReceive ('byId ' )->once ()->with (1 )->andReturn (true );
171- $ this ->auth ->shouldReceive ('user ' )->once ()->andReturn ((object ) ['id ' => 1 ]);
172+ $ this ->auth ->shouldReceive ('user ' )->once ()->andReturn ((object )['id ' => 1 ]);
172173
173174 $ user = $ this ->jwtAuth ->setToken ('foo.bar.baz ' )->customClaims (['foo ' => 'bar ' ])->authenticate ();
174175
0 commit comments