lithium\tests\cases\action\ControllerTest::testResponseTypeBasedOnRequestType PHP Метод

testResponseTypeBasedOnRequestType() публичный Метод

    public function testResponseTypeBasedOnRequestType()
    {
        $request = new MockControllerRequest();
        $request->params['type'] = 'json';
        $postsController = new MockPostsController(array('request' => $request, 'classes' => array('response' => 'lithium\\tests\\mocks\\action\\MockControllerResponse')));
        $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' => false);
        $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);
    }