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

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

    public function testCanRespondToAjax2RequestFromOkResponseBuilder()
    {
        $this->request = $this->prepareHttpRequest('foo/bar/baz', 'GET', [], 2);
        $this->createService();
        elgg_register_page_handler('foo', function ($segments, $identifier) {
            $this->assertEquals(['bar', 'baz'], $segments);
            $this->assertEquals('foo', $identifier);
            return elgg_ok_response('hello');
        });
        $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' => 'hello', '_elgg_msgs' => (object) [], '_elgg_deps' => []], ELGG_JSON_ENCODING);
        $this->assertEquals($output, $response->getContent());
    }
RouterTest