/** @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); }
/** * Decode Token From Encoded Token * * @param $encodedToken * @return Token */ public function decode(EncodedToken $encodedToken) { $stdObject = JWT::decode($encodedToken->toString(), $this->key, array('HS256')); return new Token(UserId::fromString($stdObject->userId)); }