Elgg\RouterTest::testCanFilterResponseToAjaxViewRequestForARegisteredFormView PHP Method

testCanFilterResponseToAjaxViewRequestForARegisteredFormView() public method

    public function testCanFilterResponseToAjaxViewRequestForARegisteredFormView()
    {
        $this->hooks->registerHandler('response', 'form:query_view', function ($hook, $type, $response, $params) {
            $this->assertEquals('response', $hook);
            $this->assertEquals('form:query_view', $type);
            $this->assertEquals($response, $params);
            $this->assertInstanceOf(OkResponse::class, $response);
            return elgg_error_response('good bye', REFERRER, ELGG_HTTP_BAD_REQUEST);
        });
        $vars = ['query_value' => 'hello'];
        $this->request = $this->prepareHttpRequest('ajax/form/query_view', 'GET', $vars, 1);
        $this->createService();
        elgg_register_ajax_view('form/query_view');
        $this->route();
        $response = _elgg_services()->responseFactory->getSentResponse();
        $this->assertInstanceOf(Response::class, $response);
        $this->assertEquals(ELGG_HTTP_BAD_REQUEST, $response->getStatusCode());
        $this->assertEquals('good bye', $response->getContent());
        $this->assertContains('text/html', $response->headers->get('Content-Type'));
        $this->assertContains('charset=utf-8', strtolower($response->headers->get('Content-Type')));
    }
RouterTest