mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
parent
9a8ceaeba6
commit
01b3135a63
2 changed files with 24 additions and 1 deletions
|
@ -846,6 +846,29 @@ class HashTest extends CakeTestCase {
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that extract() + matching can hit null things.
|
||||||
|
*/
|
||||||
|
public function testExtractMatchesNull() {
|
||||||
|
$data = array(
|
||||||
|
'Country' => array(
|
||||||
|
array('name' => 'Canada'),
|
||||||
|
array('name' => 'Australia'),
|
||||||
|
array('name' => null),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$result = Hash::extract($data, 'Country.{n}[name=/Canada|^$/]');
|
||||||
|
$expected = array(
|
||||||
|
array(
|
||||||
|
'name' => 'Canada',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that uneven keys are handled correctly.
|
* Test that uneven keys are handled correctly.
|
||||||
*
|
*
|
||||||
|
|
|
@ -192,7 +192,7 @@ class Hash {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Empty attribute = fail.
|
// Empty attribute = fail.
|
||||||
if (!isset($data[$attr])) {
|
if (!(isset($data[$attr]) || array_key_exists($attr, $data))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue