예제 #1
0
 /** @test */
 public function should_provide_valid_token()
 {
     $encoded_token = EncodedToken::fromNative('token');
     $this->jsonTokenService->shouldReceive('encode')->andReturn($encoded_token);
     $token = $this->tokenService->requestAccessToken($this->user);
     $this->assertInstanceOf(EncodedToken::class, $token);
 }
예제 #2
0
 /** @test */
 public function should_return_response_lol()
 {
     $credentials = ['email' => 'badEmail', 'password' => 'password'];
     $this->request->shouldReceive('only')->andReturn($credentials);
     $this->authService->shouldReceive('loginWithCredentials')->andReturn(UserStub::create());
     $this->tokenService->shouldReceive('requestAccessToken')->andReturn(EncodedToken::fromNative('token'));
     $this->transformer->shouldReceive('item')->andReturn('asdf');
     $response = $this->authController->Login($this->request);
     $this->assertInstanceOf('Illuminate\\Http\\JsonResponse', $response);
 }
예제 #3
0
 /**
  * Create a new EncodedToken
  *
  * @param $token
  * @return EncodedToken
  */
 public function encode(Token $token)
 {
     return EncodedToken::fromNative(JWT::encode($token->toArray(), $this->key));
 }