setResponsePrototype() public method

Set a response prototype to use when invoking callable middleware following http-interop middleware.
public setResponsePrototype ( Psr\Http\Message\ResponseInterface $responsePrototype ) : void
$responsePrototype Psr\Http\Message\ResponseInterface
return void
Example #1
0
 /**
  * @param ResponseInterface $prototype
  * @return void
  */
 public function setResponsePrototype(ResponseInterface $prototype)
 {
     $this->responsePrototype = $prototype;
     $this->dispatch->setResponsePrototype($prototype);
 }
 /**
  * @group http-interop
  */
 public function testProcessWillNotInjectMiddlewarePipeWithResponsePrototypeIfPipelineAlreadyHasOne()
 {
     $request = $this->prophesize(ServerRequestInterface::class)->reveal();
     $response = $this->prophesize(ResponseInterface::class)->reveal();
     $next = $this->prophesize(Next::class);
     $next->willImplement(DelegateInterface::class);
     $pipeline = $this->prophesize(MiddlewarePipe::class);
     $pipeline->hasResponsePrototype()->willReturn(true);
     $pipeline->setResponsePrototype($response)->shouldNotBeCalled();
     $pipeline->process($request, $next->reveal())->willReturn(null);
     $dispatch = new Dispatch();
     $dispatch->setResponsePrototype($response);
     $this->assertNull($dispatch->process(new Route('/', $pipeline->reveal()), $request, $next->reveal()));
 }