Elgg\RouterTest::testCanFilterResponse PHP Method

testCanFilterResponse() public method

    public function testCanFilterResponse()
    {
        $this->hooks->registerHandler('response', 'path:foo/bar', function ($hook, $type, $response, $params) {
            $this->assertEquals('response', $hook);
            $this->assertEquals('path:foo/bar', $type);
            $this->assertEquals($response, $params);
            $this->assertInstanceOf(OkResponse::class, $response);
            return elgg_error_response('', REFERRER, ELGG_HTTP_BAD_REQUEST);
        });
        $this->request = $this->prepareHttpRequest('foo/bar', 'GET');
        $this->createService();
        elgg_register_page_handler('foo', function () {
            echo 'hello';
            return true;
        });
        $this->route();
        $response = _elgg_services()->responseFactory->getSentResponse();
        $this->assertInstanceOf(Response::class, $response);
        $this->assertEquals(ELGG_HTTP_BAD_REQUEST, $response->getStatusCode());
        $this->assertEquals(elgg_view_resource('error', ['type' => (string) ELGG_HTTP_BAD_REQUEST]), $response->getContent());
    }
RouterTest