public function testCanFilterResponseToAjax2ViewRequestForARegisteredFormView()
{
$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, 2);
$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->assertContains('application/json', $response->headers->get('Content-Type'));
$output = json_encode(['error' => 'good bye'], ELGG_JSON_ENCODING);
$this->assertEquals($output, $response->getContent());
}