mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-20 08:29:55 +00:00
Make sure invalid arrays return empty array instead of throwing notices.
This commit is contained in:
parent
ef96724bc8
commit
143e8e4c56
2 changed files with 21 additions and 0 deletions
|
@ -2242,6 +2242,25 @@ class HashTest extends CakeTestCase {
|
||||||
$this->assertEquals($input, $result);
|
$this->assertEquals($input, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that nest() returns an empty array for invalid input instead of throwing notices.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testNestInvalid() {
|
||||||
|
$input = array(
|
||||||
|
array(
|
||||||
|
'ParentCategory' => array(
|
||||||
|
'id' => '1',
|
||||||
|
'name' => 'Lorem ipsum dolor sit amet',
|
||||||
|
'parent_id' => '1'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$result = Hash::nest($input);
|
||||||
|
$this->assertSame(array(), $result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testMergeDiff method
|
* testMergeDiff method
|
||||||
*
|
*
|
||||||
|
|
|
@ -1037,6 +1037,8 @@ class Hash {
|
||||||
|
|
||||||
if ($options['root']) {
|
if ($options['root']) {
|
||||||
$root = $options['root'];
|
$root = $options['root'];
|
||||||
|
} elseif (!$return) {
|
||||||
|
return array();
|
||||||
} else {
|
} else {
|
||||||
$root = self::get($return[0], $parentKeys);
|
$root = self::get($return[0], $parentKeys);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue