ZendTest\Stratigility\NextTest::testMiddlewareCallingNextWithResponseAsFirstArgumentResetsResponse PHP Method

testMiddlewareCallingNextWithResponseAsFirstArgumentResetsResponse() public method

    public function testMiddlewareCallingNextWithResponseAsFirstArgumentResetsResponse()
    {
        $cannedResponse = new Response(new PsrResponse());
        $triggered = false;
        $route1 = new Route('/foo', function ($req, $res, $next) use($cannedResponse) {
            return $next($req, $cannedResponse);
        });
        $route2 = new Route('/foo/bar', function ($req, $res, $next) use($cannedResponse, &$triggered) {
            $this->assertSame($cannedResponse, $res);
            $triggered = true;
        });
        $this->queue->enqueue($route1);
        $this->queue->enqueue($route2);
        $done = function ($req, $res, $err) {
            $this->fail('Should not hit final handler');
        };
        $request = $this->request->withUri(new Uri('http://example.com/foo/bar/baz'));
        $next = new Next($this->queue, $done);
        $result = $next($request, $this->response);
        $this->assertTrue($triggered);
        $this->assertSame($cannedResponse, $result);
    }
NextTest