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