Elgg\ActionsServiceTest::testCanRespondToAjaxRequestFromRedirectResponseBuilder PHP Method

testCanRespondToAjaxRequestFromRedirectResponseBuilder() public method

    public function testCanRespondToAjaxRequestFromRedirectResponseBuilder()
    {
        $this->assertTrue($this->actions->register('output4', "{$this->actionsDir}/output4.php", 'public'));
        $this->request = $this->prepareHttpRequest('action/output4', 'POST', [], 1, true);
        $this->createService();
        set_input('output', ['foo', 'bar']);
        set_input('forward_reason', ELGG_HTTP_FOUND);
        set_input('forward_url', 'index');
        $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' => '', 'status' => 0, 'system_messages' => ['error' => [], 'success' => []], 'current_url' => current_page_url(), 'forward_url' => elgg_normalize_url('index')]);
        $this->assertEquals($output, $response->getContent());
    }
ActionsServiceTest