@@ 157-171 (lines=15) @@ | ||
154 | /** |
|
155 | * @test |
|
156 | */ |
|
157 | public function authenticateTokenWillSetUserFetchedFromUserProviderOnToken() |
|
158 | { |
|
159 | $jwtAuthenticationProvider = new JwtAuthenticationProvider($this->standardUserProviderMock, $this->keys); |
|
160 | $authToken = new JwtAuthenticationToken([], self::TEST_TOKEN); |
|
161 | ||
162 | /** @var \PHPUnit_Framework_MockObject_MockObject $mock */ |
|
163 | $mock = $this->standardUserProviderMock; |
|
164 | $mock |
|
165 | ->expects($this->once()) |
|
166 | ->method('loadUserByUsername') |
|
167 | ->with('john') |
|
168 | ->willReturn(new User('john', 'hi there')); |
|
169 | ||
170 | $jwtAuthenticationProvider->authenticate($authToken); |
|
171 | } |
|
172 | ||
173 | /** |
|
174 | * @test |
|
@@ 191-207 (lines=17) @@ | ||
188 | * @test |
|
189 | * @expectedException \UnexpectedValueException |
|
190 | */ |
|
191 | public function authenticateTokenWillWillNotCallUserProviderWhenTokenStringInvalid() |
|
192 | { |
|
193 | $jwtAuthenticationProvider = new JwtAuthenticationProvider($this->standardUserProviderMock, $this->keys); |
|
194 | $authToken = new JwtAuthenticationToken([], 'invalid'); |
|
195 | ||
196 | /** @var \PHPUnit_Framework_MockObject_MockObject $mock */ |
|
197 | $mock = $this->standardUserProviderMock; |
|
198 | $mock |
|
199 | ->expects($this->never()) |
|
200 | ->method('loadUserByUsername') |
|
201 | ->with('john') |
|
202 | ->willReturn(new User('john', 'hi there')); |
|
203 | ||
204 | $this->expectException(BadCredentialsException::class); |
|
205 | ||
206 | $jwtAuthenticationProvider->authenticate($authToken); |
|
207 | } |
|
208 | ||
209 | /** |
|
210 | * @test |