Elgg\RouterTest::testCanRedirectAjax2RequestFromRouteHook PHP Method

testCanRedirectAjax2RequestFromRouteHook() public method

    public function testCanRedirectAjax2RequestFromRouteHook()
    {
        $this->hooks->registerHandler('route', 'foo', function ($hook, $type, $return, $params) {
            $this->assertEquals($return, $params);
            $this->assertEquals('foo', $return['identifier']);
            $this->assertEquals(['bar', 'baz'], $return['segments']);
            _elgg_services()->responseFactory->redirect('foo2/bar2/baz2');
            return false;
        });
        $this->request = $this->prepareHttpRequest('foo/bar/baz', 'GET', [], 2);
        $this->createService();
        $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' => '', '_elgg_msgs' => (object) [], '_elgg_deps' => []], ELGG_JSON_ENCODING);
        $this->assertEquals($output, $response->getContent());
        // compensate for fact that ResponseFactory::redirect closes a buffer it didn't open
        ob_start();
    }
RouterTest