Elgg\RouterTest::testCanRespondToAjax2RequestInNonDefaultViewtype PHP Method

testCanRespondToAjax2RequestInNonDefaultViewtype() public method

    public function testCanRespondToAjax2RequestInNonDefaultViewtype()
    {
        $this->request = $this->prepareHttpRequest('phpunit', 'GET', ['view' => 'json'], 2);
        $this->createService();
        elgg_register_page_handler('phpunit', function () {
            $output = elgg_view('response');
            return elgg_ok_response($output);
        });
        $this->assertTrue($this->route());
        $response = _elgg_services()->responseFactory->getSentResponse();
        $this->assertInstanceOf(Response::class, $response);
        $this->assertEquals(ELGG_HTTP_OK, $response->getStatusCode());
        $this->assertContains('application/json', $response->headers->get('Content-Type'));
        $output = json_encode(['value' => ['foo' => 'bar'], '_elgg_msgs' => (object) [], '_elgg_deps' => []], ELGG_JSON_ENCODING);
        $this->assertEquals($output, $response->getContent());
    }
RouterTest