mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
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:
parent
93bf4fd0dc
commit
056402efa7
2 changed files with 8 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue