mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch 'torifat-set' into 1.3
This commit is contained in:
commit
5273080962
2 changed files with 41 additions and 7 deletions
|
@ -431,6 +431,13 @@ class Set {
|
|||
'key' => $key,
|
||||
'item' => array_keys($context['item']),
|
||||
);
|
||||
} elseif (($key === $token || (ctype_digit($token) && $key == $token) || $token === '.')) {
|
||||
$context['trace'][] = $key;
|
||||
$matches[] = array(
|
||||
'trace' => $context['trace'],
|
||||
'key' => $key,
|
||||
'item' => $context['item'],
|
||||
);
|
||||
} elseif (is_array($context['item']) && array_key_exists($token, $context['item'])) {
|
||||
$items = $context['item'][$token];
|
||||
if (!is_array($items)) {
|
||||
|
@ -470,13 +477,6 @@ class Set {
|
|||
'item' => $item,
|
||||
);
|
||||
}
|
||||
} elseif (($key === $token || (ctype_digit($token) && $key == $token) || $token === '.')) {
|
||||
$context['trace'][] = $key;
|
||||
$matches[] = array(
|
||||
'trace' => $context['trace'],
|
||||
'key' => $key,
|
||||
'item' => $context['item'],
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($conditions) {
|
||||
|
|
|
@ -939,6 +939,40 @@ class SetTest extends CakeTestCase {
|
|||
$result = Set::extract('/ParentNode/name', $hasMany);
|
||||
$expected = array('Second');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$data = array(
|
||||
array(
|
||||
'Category' => array(
|
||||
'id' => 1,
|
||||
'name' => 'First'
|
||||
),
|
||||
0 => array(
|
||||
'value' => 50
|
||||
)
|
||||
),
|
||||
array(
|
||||
'Category' => array(
|
||||
'id' => 2,
|
||||
'name' => 'Second'
|
||||
),
|
||||
0 => array(
|
||||
'value' => 60
|
||||
)
|
||||
)
|
||||
);
|
||||
$expected = array(
|
||||
array(
|
||||
'Category' => array(
|
||||
'id' => 1,
|
||||
'name' => 'First'
|
||||
),
|
||||
0 => array(
|
||||
'value' => 50
|
||||
)
|
||||
)
|
||||
);
|
||||
$result = Set::extract('/Category[id=1]/..', $data);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue