/** * @param ResponseInterface $prototype * @return void */ public function setResponsePrototype(ResponseInterface $prototype) { $this->responsePrototype = $prototype; $this->dispatch->setResponsePrototype($prototype); }
/** * @dataProvider throwablesProvider * @group error-handling */ public function testThrowsThrowablesRaisedByInteropMiddlewareWhenRaiseThrowablesFlagIsEnabled($throwable) { $middleware = $this->prophesize(ServerMiddlewareInterface::class); $middleware->process(Argument::type(ServerRequestInterface::class), Argument::type(DelegateInterface::class))->will(function () use($throwable) { throw $throwable; }); $route = new Route('/', $middleware->reveal()); $next = $this->prophesize(Next::class); $next->__invoke(Argument::type(ServerRequestInterface::class), Argument::type(ResponseInterface::class), $throwable)->shouldNotBeCalled(); $dispatch = new Dispatch(); $dispatch->raiseThrowables(); try { $dispatch->process($route, $this->request->reveal(), $next->reveal()); $this->fail('Dispatch succeeded and should not have'); } catch (\Throwable $e) { $this->assertSame($throwable, $e, sprintf('Throwable raised is not the one expected: %s', $e->getMessage())); } catch (\Exception $e) { $this->assertSame($throwable, $e, sprintf('Exception raised is not the one expected: %s', $e->getMessage())); } }