mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
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:
parent
953db61447
commit
8fadcbafea
1 changed files with 65 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue