diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index 01547024a..db30e3e85 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -30,6 +30,11 @@ App::uses('JsonView', 'View'); */ class JsonViewTest extends CakeTestCase { + public function setUp() { + parent::setUp(); + Configure::write('debug', 0); + } + /** * testRenderWithoutView method * diff --git a/lib/Cake/Test/Case/View/XmlViewTest.php b/lib/Cake/Test/Case/View/XmlViewTest.php index 8d150e737..b6f860947 100644 --- a/lib/Cake/Test/Case/View/XmlViewTest.php +++ b/lib/Cake/Test/Case/View/XmlViewTest.php @@ -30,6 +30,11 @@ App::uses('XmlView', 'View'); */ class XmlViewTest extends CakeTestCase { + public function setUp() { + parent::setUp(); + Configure::write('debug', 0); + } + /** * testRenderWithoutView method * diff --git a/lib/Cake/View/JsonView.php b/lib/Cake/View/JsonView.php index 3cb81ca97..7ffeb8673 100644 --- a/lib/Cake/View/JsonView.php +++ b/lib/Cake/View/JsonView.php @@ -128,6 +128,11 @@ class JsonView extends View { } else { $data = isset($this->viewVars[$serialize]) ? $this->viewVars[$serialize] : null; } + + if (version_compare(PHP_VERSION, '5.4.0', '>=') && Configure::read('debug')) { + return json_encode($data, JSON_PRETTY_PRINT); + } + return json_encode($data); } diff --git a/lib/Cake/View/XmlView.php b/lib/Cake/View/XmlView.php index 0dbd61775..f218e389b 100644 --- a/lib/Cake/View/XmlView.php +++ b/lib/Cake/View/XmlView.php @@ -116,7 +116,13 @@ class XmlView extends View { $data = array($rootNode => array($serialize => $data)); } } - return Xml::fromArray($data)->asXML(); + + $options = array(); + if (Configure::read('debug')) { + $options['pretty'] = true; + } + + return Xml::fromArray($data, $options)->asXML(); } }