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); }