From ddc39021209a767921d723e7a198169aae6381ad Mon Sep 17 00:00:00 2001 From: ADmad Date: Wed, 30 Sep 2015 03:03:39 +0530 Subject: [PATCH] Change how a single view var is inferred with `'_serialize' => true` Now if a single view var is set it's inferred as `'_serialize' => ['var']` instead of `'_serialize' => 'var'`. Closes #7482 --- src/View/JsonView.php | 4 ---- tests/TestCase/View/JsonViewTest.php | 8 ++++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/View/JsonView.php b/src/View/JsonView.php index 1fd2276e9fc..77d3c581bb4 100644 --- a/src/View/JsonView.php +++ b/src/View/JsonView.php @@ -173,10 +173,6 @@ protected function _dataToSerialize($serialize = true) return null; } - if (count($data) === 1) { - return current($data); - } - return $data; } diff --git a/tests/TestCase/View/JsonViewTest.php b/tests/TestCase/View/JsonViewTest.php index 7c910d43763..396e878ed73 100644 --- a/tests/TestCase/View/JsonViewTest.php +++ b/tests/TestCase/View/JsonViewTest.php @@ -119,6 +119,14 @@ public static function renderWithoutViewProvider() json_encode(['no' => 'nope', 'user' => 'fake', 'list' => ['item1', 'item2']]) ], + // Test render with True in _serialize and single var + [ + ['no' => 'nope'], + true, + null, + json_encode(['no' => 'nope']) + ], + // Test render with empty string in _serialize. [ ['no' => 'nope', 'user' => 'fake', 'list' => ['item1', 'item2']],