Partial fix for #5225

Corrected expected behavior for 2nd issue

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7633 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
the_undefined 2008-09-19 18:08:27 +00:00
parent 931d996d90
commit 740bd4e769
2 changed files with 6 additions and 15 deletions

View file

@ -397,6 +397,9 @@ class Set extends Object {
$context = array('trace' => array(), 'item' => $context, 'key' => null);
}
if ($token === '..') {
if (count($context['trace']) == 1) {
$context['trace'][] = $context['key'];
}
$parent = join('/', $context['trace']).'['.($key+1).']';
$context['item'] = Set::extract($parent, $data);
$context['key'] = array_pop($context['trace']);

View file

@ -727,20 +727,8 @@ class SetTest extends CakeTestCase {
)
)
);
$expected = array(
array(
'Category' => array(
'name' => 'Category 2'
),
'children' => array(
array(
'Category' => array(
'name' => 'Category 2.1'
)
)
)
)
);
$expected = array(array('Category' => $tree[0]['Category']));
$r = Set::extract('/Category[name=Category 2]/..', $tree);
$this->assertEqual($r, $expected);
@ -751,7 +739,7 @@ class SetTest extends CakeTestCase {
)
)
);
$r = Set::extract('/Category[name=Category 2]/../children/.', $tree);
$r = Set::extract('/Category[name=Category 2]/../../children', $tree);
$this->assertEqual($r, $expected);
}
/**