Elgg\RouterTest::testCanRespondToAjaxRequestInNonDefaultViewtype PHP Метод

testCanRespondToAjaxRequestInNonDefaultViewtype() публичный Метод

    public function testCanRespondToAjaxRequestInNonDefaultViewtype()
    {
        $this->request = $this->prepareHttpRequest('phpunit', 'GET', ['view' => 'json'], 1);
        $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'));
        $this->assertContains('charset=utf-8', strtolower($response->headers->get('Content-Type')));
        // no forward, so API outputs view contents
        $this->assertEquals(elgg_view('response', [], false, false, 'json'), $response->getContent());
    }
RouterTest