ZendTest\Stratigility\DispatchTest::testThrowsThrowablesRaisedByErrorMiddlewareWhenRaiseThrowablesFlagIsEnabled PHP Метод

testThrowsThrowablesRaisedByErrorMiddlewareWhenRaiseThrowablesFlagIsEnabled() публичный Метод

    public function testThrowsThrowablesRaisedByErrorMiddlewareWhenRaiseThrowablesFlagIsEnabled($throwable)
    {
        $middleware = $this->prophesize(ErrorMiddlewareInterface::class);
        $middleware->__invoke($throwable, Argument::type(ServerRequestInterface::class), Argument::type(ResponseInterface::class), Argument::type(Next::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($route, $throwable, $this->request->reveal(), $this->response->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()));
        }
    }
DispatchTest