public function testIsEmpty()
 {
     $empty_transport = new AuthenticationTransport(new TokenBearerAdapter(new UserRepository(), new TokenRepository()), null, null);
     $this->assertTrue($empty_transport->isEmpty());
     $not_empty_transport = new AuthenticationTransport(new TokenBearerAdapter(new UserRepository(), new TokenRepository()), new AuthenticatedUser(1, '*****@*****.**', 'John Doe', 'secret'), new Token('123', 1));
     $this->assertFalse($not_empty_transport->isEmpty());
 }
 public function testAuthenticationTransportSetsAttributes()
 {
     $transport = new AuthenticationTransport($this->token_bearer_adapter, $this->user, $this->token);
     $this->assertFalse($transport->isEmpty());
     $this->assertFalse($transport->isApplied());
     /** @var ServerRequestInterface $request */
     /** @var ResponseInterface $response */
     list($request, $response) = $transport->applyTo($this->request, $this->response);
     $this->assertInstanceOf(ServerRequestInterface::class, $request);
     $this->assertInstanceOf(ResponseInterface::class, $response);
     $this->assertTrue($transport->isApplied());
     $this->assertArrayHasKey('authentication_adapter', $request->getAttributes());
     $this->assertArrayHasKey('authenticated_user', $request->getAttributes());
     $this->assertArrayHasKey('authenticated_with', $request->getAttributes());
 }
 /**
  * @expectedException \LogicException
  * @expectedExceptionMessage Authentication transport already applied
  */
 public function testTransportCantBeAppliedTwice()
 {
     $transport = new AuthenticationTransport($this->token_bearer_adapter, $this->user, $this->token);
     $this->assertFalse($transport->isApplied());
     $transport->applyTo($this->request, $this->response);
     $this->assertTrue($transport->isApplied());
     $transport->applyTo($this->request, $this->response);
 }