| @@ 96-111 (lines=16) @@ | ||
| 93 | /** |
|
| 94 | * testGetUserIdFromTokenWithInvalidClaim method |
|
| 95 | */ |
|
| 96 | public function testGetUserIdFromTokenWithInvalidClaim() |
|
| 97 | { |
|
| 98 | $token = $this->getToken(); |
|
| 99 | ||
| 100 | $this->claimManager->shouldReceive('check') |
|
| 101 | ->once() |
|
| 102 | ->with(Mockery::on(function($claim) { |
|
| 103 | return $claim->sub == 5 |
|
| 104 | && $claim->iss == 'http://www.test.com'; |
|
| 105 | })) |
|
| 106 | ->andReturn(false); |
|
| 107 | ||
| 108 | $this->setExpectedException(\WWON\JwtGuard\Exceptions\InvalidTokenException::class); |
|
| 109 | ||
| 110 | $claim = $this->jwtService->getClaimFromToken($token); |
|
| 111 | } |
|
| 112 | ||
| 113 | /** |
|
| 114 | * testRefreshToken method |
|
| @@ 151-168 (lines=18) @@ | ||
| 148 | /** |
|
| 149 | * testRefreshUnRefreshableToken method |
|
| 150 | */ |
|
| 151 | public function testRefreshUnRefreshableToken() |
|
| 152 | { |
|
| 153 | $now = Carbon::now()->timestamp; |
|
| 154 | ||
| 155 | $token = $this->getToken(); |
|
| 156 | ||
| 157 | $this->claimManager->shouldReceive('check') |
|
| 158 | ->once() |
|
| 159 | ->with(Mockery::on(function($claim) { |
|
| 160 | return $claim->sub == 5 |
|
| 161 | && $claim->iss == 'http://www.test.com'; |
|
| 162 | })) |
|
| 163 | ->andReturn(true); |
|
| 164 | ||
| 165 | $this->setExpectedException(\WWON\JwtGuard\Exceptions\UnRefreshableException::class); |
|
| 166 | ||
| 167 | $newToken = $this->jwtService->refreshToken($token); |
|
| 168 | } |
|
| 169 | ||
| 170 | /** |
|
| 171 | * testInvalidateToken method |
|