From 056402efa708d986b9da283d5f5b831840cdabcd Mon Sep 17 00:00:00 2001 From: gwoo Date: Sun, 15 Mar 2009 19:39:35 +0000 Subject: [PATCH] moving checks for Set::extract() so that null will be returned when empty data is passed and classicExtract is expected. git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8105 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/set.php | 6 +++--- cake/tests/cases/libs/set.test.php | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cake/libs/set.php b/cake/libs/set.php index 4376f5c05..bed03379a 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -374,12 +374,12 @@ class Set extends Object { $data = $path; $path = $tmp; } - if (empty($data)) { - return array(); - } if (strpos($path, '/') === false) { return Set::classicExtract($data, $path); } + if (empty($data)) { + return array(); + } if ($path === '/') { return $data; } diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index ed2f4f04c..81f884394 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -1052,15 +1052,17 @@ class SetTest extends CakeTestCase { */ function testSetExtractReturnsEmptyArray() { - $this->assertEqual(Set::extract(array(), '/Post/id'), array()); + $this->assertIdentical(Set::extract(array(), '/Post/id'), array()); - $this->assertEqual(Set::extract('/Post/id', array()), array()); + $this->assertIdentical(Set::extract('/Post/id', array()), array()); - $this->assertEqual(Set::extract('/Post/id', array( + $this->assertIdentical(Set::extract('/Post/id', array( array('Post' => array('name' => 'bob')), array('Post' => array('name' => 'jim')) )), array()); + $this->assertIdentical(Set::extract(array(), 'Message.flash'), null); + } /** * testClassicExtract method