ZendTest\Stratigility\NextTest::testProcessReinvokesItselfWhenRouteDoesNotMatchCurrentUrl PHP Method

testProcessReinvokesItselfWhenRouteDoesNotMatchCurrentUrl() public method

    public function testProcessReinvokesItselfWhenRouteDoesNotMatchCurrentUrl()
    {
        // e.g., handler matches "/foo", but path is "/bar"
        $done = function ($req, $res, $err = null) {
            Assert::fail('Should not have hit the done handler, but did, with error: ' . var_export($err, true));
        };
        $request = $this->request->withUri(new Uri('http://local.example.com/bar'));
        $response = $this->prophesize(ResponseInterface::class)->reveal();
        $first = $this->prophesize(ServerMiddlewareInterface::class);
        $first->process($request, Argument::type(Next::class))->will(function () {
            // This one should be skipped
            Assert::fail('Route should not be invoked if path does not match');
        });
        $this->queue->enqueue(new Route('/foo', $first->reveal()));
        $second = $this->prophesize(ServerMiddlewareInterface::class);
        $second->process(Argument::type(RequestInterface::class), Argument::type(Next::class))->willReturn($response);
        $this->queue->enqueue(new Route('/bar', $second->reveal()));
        $next = new Next($this->queue, $done);
        $next->setResponsePrototype($response);
        $this->assertSame($response, $next->process($request));
    }
NextTest