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

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

    public function testThrowsThrowablesRaisedByNextMiddlewareWhenRaiseThrowablesFlagIsEnabled($middleware, $throwable)
    {
        $route = new Route('/', $middleware);
        $next = $this->prophesize(Next::class);
        $next->__invoke(Argument::type(ServerRequestInterface::class), Argument::type(ResponseInterface::class), $throwable)->will(function () use($throwable) {
            if (null === $throwable) {
                return $throwable;
            }
            throw $throwable;
        });
        $dispatch = new Dispatch();
        $dispatch->raiseThrowables();
        if (null === $throwable) {
            $this->assertNull($dispatch($route, $throwable, $this->request->reveal(), $this->response->reveal(), $next->reveal()));
            return;
        }
        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