Making JsonView work more like the XmlView.

This commit is contained in:
mark_story 2011-11-07 21:46:52 -05:00
parent 011fd51539
commit 5e9b1583e5
3 changed files with 14 additions and 2 deletions

View file

@ -53,10 +53,14 @@ class JsonViewTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testRenderWithView() { public function testRenderWithView() {
App::build(array('View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Json'))); App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$Request = new CakeRequest(); $Request = new CakeRequest();
$Response = new CakeResponse(); $Response = new CakeResponse();
$Controller = new Controller($Request, $Response); $Controller = new Controller($Request, $Response);
$Controller->name = $Controller->viewPath = 'Posts';
$data = array( $data = array(
'User' => array( 'User' => array(
'username' => 'fake' 'username' => 'fake'

View file

@ -24,4 +24,4 @@ foreach ($user['Item'] as $item) {
$formatted['list'][] = $item['name']; $formatted['list'][] = $item['name'];
} }
$this->set('serialize', $formatted); echo json_encode($formatted);

View file

@ -36,6 +36,14 @@ App::uses('View', 'View');
*/ */
class JsonView extends View { class JsonView extends View {
/**
* JSON views are always located in the 'json' sub directory for a
* controllers views.
*
* @var string
*/
public $subDir = 'json';
/** /**
* Constructor * Constructor
* *