Zend\Stratigility\Next::setResponsePrototype PHP Method

setResponsePrototype() public method

public setResponsePrototype ( Psr\Http\Message\ResponseInterface $prototype ) : void
$prototype Psr\Http\Message\ResponseInterface
return void
    public function setResponsePrototype(ResponseInterface $prototype)
    {
        $this->responsePrototype = $prototype;
        $this->dispatch->setResponsePrototype($prototype);
    }

Usage Example

コード例 #1
0
 /**
  * @todo Remove the $done argument during setup for 2.0.0
  * @group http-interop
  */
 public function testProcessReturnsResponsePrototypeIfNoResponseReturnedByMiddleware()
 {
     $done = function ($req, $res, $err = null) {
         Assert::fail('Should not have hit the done handler, but did');
     };
     $request = $this->request->withUri(new Uri('http://example.com/foo/bar/baz'));
     $response = $this->prophesize(ResponseInterface::class)->reveal();
     $route1 = $this->prophesize(ServerMiddlewareInterface::class);
     $route1->process(Argument::that(function ($arg) {
         Assert::assertEquals('/bar/baz', $arg->getUri()->getPath());
         return true;
     }), Argument::type(Next::class))->willReturn('foobar');
     $this->queue->enqueue(new Route('/foo', $route1->reveal()));
     $route2 = $this->prophesize(ServerMiddlewareInterface::class);
     $route2->process(Argument::type(RequestInterface::class), Argument::type(Next::class))->shouldNotBeCalled();
     $this->queue->enqueue(new Route('/foo/bar', $route2->reveal()));
     $next = new Next($this->queue, $done);
     $next->setResponsePrototype($response);
     $this->assertSame($response, $next->process($request));
 }
All Usage Examples Of Zend\Stratigility\Next::setResponsePrototype