public function testCanRespondToAjaxRequestFromErrorResponseBuilder()
{
$this->request = $this->prepareHttpRequest('foo/bar/baz', 'GET', [], 1);
$this->createService();
elgg_register_page_handler('foo', function ($segments, $identifier) {
$this->assertEquals(['bar', 'baz'], $segments);
$this->assertEquals('foo', $identifier);
return elgg_error_response('', 'phpunit', ELGG_HTTP_NOT_FOUND);
});
$this->assertTrue($this->route());
$response = _elgg_services()->responseFactory->getSentResponse();
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(ELGG_HTTP_NOT_FOUND, $response->getStatusCode());
$this->assertContains('text/html', $response->headers->get('Content-Type'));
$this->assertContains('charset=utf-8', strtolower($response->headers->get('Content-Type')));
// no forward, so API outputs html
$this->assertEquals('', $response->getContent());
}