lithium\tests\cases\action\ControllerTest::testRedirectResponse PHP Method

testRedirectResponse() public method

Tests that calls to Controller::redirect() correctly write redirect headers to the response object.
    public function testRedirectResponse()
    {
        $postsController = new MockPostsController();
        $result = $postsController(null, array('action' => 'delete'));
        $this->assertEqual($result->body(), '');
        $headers = array('Location' => '/posts', 'Content-Type' => 'text/html');
        $this->assertEqual($result->headers, $headers);
        $postsController = new MockPostsController();
        $result = $postsController(null, array('action' => 'delete', 'args' => array('5')));
        $this->assertEqual($result->body(), 'Deleted 5');
        $this->assertFalse($postsController->stopped);
        $postsController = new MockPostsController(array('classes' => array('response' => 'lithium\\tests\\mocks\\action\\MockControllerResponse')));
        $this->assertFalse($postsController->stopped);
        $postsController->__invoke(null, array('action' => 'send'));
        $this->assertTrue($postsController->stopped);
        $result = $postsController->access('_render');
        $this->assertTrue($result['hasRendered']);
        $this->assertEqual($postsController->response->body(), null);
        $this->assertEqual($postsController->response->headers, array('Location' => '/posts', 'Content-Type' => 'text/html'));
    }