mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
fix for Set::reverse() with _name_
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7495 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
d8e1778a0d
commit
921a5770db
2 changed files with 18 additions and 3 deletions
|
@ -98,7 +98,10 @@ class Set extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function pushDiff($array, $array2) {
|
||||
if (!empty($array2)) {
|
||||
if (empty($array) && !empty($array2)) {
|
||||
return $array2;
|
||||
}
|
||||
if (!empty($array) && !empty($array2)) {
|
||||
foreach ($array2 as $key => $value) {
|
||||
if (!array_key_exists($key, $array)) {
|
||||
$array[$key] = $value;
|
||||
|
@ -914,8 +917,8 @@ class Set extends Object {
|
|||
if (is_array($value)) {
|
||||
$new[$key] = (array)Set::reverse($value);
|
||||
} else {
|
||||
if (isset($value->_name_)){
|
||||
$new = Set::reverse($value);
|
||||
if (isset($value->_name_)) {
|
||||
$new = array_merge($new, Set::reverse($value));
|
||||
} else {
|
||||
$new[$key] = Set::reverse($value);
|
||||
}
|
||||
|
|
|
@ -1361,6 +1361,18 @@ class SetTest extends CakeTestCase {
|
|||
$result = Set::reverse($class);
|
||||
$expected = array('User' => array('id' => '100'), 'someString'=> 'this is some string', 'Profile' => array('name' => 'Joe Mamma'));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$class = new stdClass;
|
||||
$class->User = new stdClass;
|
||||
$class->User->id = 100;
|
||||
$class->User->_name_ = 'User';
|
||||
$class->Profile = new stdClass;
|
||||
$class->Profile->name = 'Joe Mamma';
|
||||
$class->Profile->_name_ = 'Profile';
|
||||
|
||||
$result = Set::reverse($class);
|
||||
$expected = array('User' => array('id' => '100'), 'Profile' => array('name' => 'Joe Mamma'));
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testFormatting method
|
||||
|
|
Loading…
Reference in a new issue