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

testResponseTypeBasedOnRequestHeaderType() public method

    public function testResponseTypeBasedOnRequestHeaderType()
    {
        $request = new MockControllerRequest(array('env' => array('HTTP_ACCEPT' => 'application/json,*/*')));
        $postsController = new MockPostsController(array('request' => $request, 'classes' => array('response' => 'lithium\\tests\\mocks\\action\\MockControllerResponse'), 'render' => array('negotiate' => true)));
        $this->assertFalse($postsController->stopped);
        $postsController($request, array('action' => 'type'));
        $expected = array('type' => 'json', 'data' => array('data' => 'test'), 'auto' => true, 'layout' => 'default', 'template' => 'type', 'hasRendered' => true, 'negotiate' => true);
        $result = $postsController->access('_render');
        $this->assertEqual($expected, $result);
        $result = $postsController->response->headers('Content-Type');
        $this->assertEqual('application/json; charset=UTF-8', $result);
        $result = $postsController->response->body();
        $this->assertEqual(array('data' => 'test'), $result);
    }