/** * @test */ public function responderResolverReturnsFirstMatch() { $domainPayload = new DomainPayload('test'); $this->action->expects($this->once())->method('prepareAndExecute')->will($this->returnValue($domainPayload)); $this->router->expects($this->once())->method('resolveActionToken')->will($this->returnValue($this->request)); $returnValue = $this->buildResponse('<html>', 200); $this->responder->expects($this->once())->method('buildResponse')->will($this->returnValue($returnValue)); $this->responderResolver->expects($this->once())->method('resolve')->will($this->returnValue($this->responder)); $responderResolver2 = $this->getMock(ResponderResolver::class); $responderResolver2->expects($this->never())->method('resolve'); $this->middleware = $this->getMock(AdroitMiddleware::class, ['resolveAction'], [[], [$this->responderResolver, $responderResolver2], $this->router]); $this->middleware->expects($this->once())->method('resolveAction')->will($this->returnValue($this->action)); $response = $this->middleware->__invoke($this->request, new Response()); $this->assertSame($returnValue, $response); }
/** * @inheritdoc */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $out = null) { if ($this->errorHandler) { $out = $this->encapsulateErrorHandler($this->errorHandler, $out); } $response = parent::__invoke($request, $response, $out); $this->emitter->emit($response); }