Elgg\RouterTest::testCanRespondToAjaxViewRequestForARegisteredViewWhichForwards PHP Method

testCanRespondToAjaxViewRequestForARegisteredViewWhichForwards() public method

    public function testCanRespondToAjaxViewRequestForARegisteredViewWhichForwards()
    {
        $vars = ['output' => 'hello', 'forward_url' => 'forwards', 'forward_reason' => ELGG_HTTP_BAD_REQUEST, 'error' => 'error'];
        $this->request = $this->prepareHttpRequest('ajax/view/forwards', 'GET', $vars, 1);
        $this->createService();
        elgg_register_ajax_view('forwards');
        $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')));
        $output = json_encode(['output' => 'hello', 'status' => -1, 'system_messages' => ['error' => ['error'], 'success' => []], 'current_url' => current_page_url(), 'forward_url' => elgg_normalize_url('forwards')], ELGG_JSON_ENCODING);
        $this->assertEquals($output, $response->getContent());
        // compensate for fact that ResponseFactory::redirect closes a buffer it didn't open
        ob_start();
    }
RouterTest