Added test to show parent transversal bug. Merged patch from 'sneeka2'. Refs #5225

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7626 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
renan.saddam 2008-09-19 00:01:48 +00:00
parent 953db61447
commit 8fadcbafea

View file

@ -688,6 +688,71 @@ class SetTest extends CakeTestCase {
$this->assertEqual($r[0]['Comment']['User']['name'], 'bob');
$this->assertEqual($r[1]['Comment']['User']['name'], 'tod');
$this->assertEqual(count($r), 2);
$tree = array(
array(
'Category' => array(
'name' => 'Category 1'
),
'children' => array(
array(
'Category' => array(
'name' => 'Category 1.1'
)
)
)
),
array(
'Category' => array(
'name' => 'Category 2'
),
'children' => array(
array(
'Category' => array(
'name' => 'Category 2.1'
)
)
)
),
array(
'Category' => array(
'name' => 'Category 3'
),
'children' => array(
array(
'Category' => array(
'name' => 'Category 3.1'
)
)
)
)
);
$expected = array(
array(
'Category' => array(
'name' => 'Category 2'
),
'children' => array(
array(
'Category' => array(
'name' => 'Category 2.1'
)
)
)
)
);
$r = Set::extract('/Category[name=Category 2]/..', $tree);
$this->assertEqual($r, $expected);
$expected = array(
array(
'Category' => array(
'name' => 'Category 2.1'
)
)
);
$r = Set::extract('/Category[name=Category 2]/../children/.', $tree);
$this->assertEqual($r, $expected);
}
/**
* testMatches method