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
This commit is contained in:
gwoo 2009-03-15 19:39:35 +00:00
parent 93bf4fd0dc
commit 056402efa7
2 changed files with 8 additions and 6 deletions

View file

@ -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;
}

View file

@ -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