diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index 47ba9f2b2..a3b0c5ef3 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -53,10 +53,14 @@ class JsonViewTest extends CakeTestCase { * @return void */ 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(); $Response = new CakeResponse(); $Controller = new Controller($Request, $Response); + $Controller->name = $Controller->viewPath = 'Posts'; + $data = array( 'User' => array( 'username' => 'fake' diff --git a/lib/Cake/Test/test_app/View/Json/index.ctp b/lib/Cake/Test/test_app/View/Posts/json/index.ctp similarity index 95% rename from lib/Cake/Test/test_app/View/Json/index.ctp rename to lib/Cake/Test/test_app/View/Posts/json/index.ctp index 13e0269b5..a03f59e37 100644 --- a/lib/Cake/Test/test_app/View/Json/index.ctp +++ b/lib/Cake/Test/test_app/View/Posts/json/index.ctp @@ -24,4 +24,4 @@ foreach ($user['Item'] as $item) { $formatted['list'][] = $item['name']; } -$this->set('serialize', $formatted); +echo json_encode($formatted); diff --git a/lib/Cake/View/JsonView.php b/lib/Cake/View/JsonView.php index aae0ac976..4d5e1a215 100644 --- a/lib/Cake/View/JsonView.php +++ b/lib/Cake/View/JsonView.php @@ -36,6 +36,14 @@ App::uses('View', '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 *