public function testResponseTypeBasedOnRequestParamsType() {
$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->__invoke($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);
$expected = array('data' => 'test');
$result = json_decode($postsController->response->body(), true);
$this->assertEqual($expected, $result);
}