ZendTest\Stratigility\MiddlewarePipeTest::testOmittingFinalHandlerDuringInvocationRaisesDeprecationNotice PHP Method

testOmittingFinalHandlerDuringInvocationRaisesDeprecationNotice() public method

    public function testOmittingFinalHandlerDuringInvocationRaisesDeprecationNotice()
    {
        $request = new Request([], [], 'http://local.example.com/foo', 'GET', 'php://memory');
        $response = new Response();
        $triggered = false;
        $this->deprecationsSuppressed = set_error_handler(function ($errno, $errstr) use(&$triggered) {
            if (false !== strstr($errstr, ResponseDecorator::class)) {
                // ignore response decorator deprecation message
                return true;
            }
            $this->assertContains(MiddlewarePipe::class . '()', $errstr);
            $triggered = true;
            return true;
        }, E_USER_DEPRECATED);
        $pipeline = new MiddlewarePipe();
        $pipeline->pipe(function ($req, $res, $next) {
            $res->write('Some content');
            return $res->withStatus(201);
        });
        $result = $pipeline($request, $response);
        $this->assertNotSame($response, $result);
        $this->assertEquals(201, $result->getStatusCode());
        $this->assertEquals('Some content', (string) $result->getBody());
        $this->assertTrue($triggered, 'Error handler was not triggered');
    }
MiddlewarePipeTest