/** @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); }
/** @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); }
/** * Create a new EncodedToken * * @param $token * @return EncodedToken */ public function encode(Token $token) { return EncodedToken::fromNative(JWT::encode($token->toArray(), $this->key)); }