Fixed a bug in Set::extract. Wrong key returned when two arrays are at the extraction level.

Signed-off-by: Mark Story <mark@mark-story.com>
This commit is contained in:
real34 2009-12-14 11:02:35 +01:00 committed by Mark Story
parent 4ac29963a8
commit bdfb50e6bb
2 changed files with 16 additions and 1 deletions

View file

@ -454,7 +454,7 @@ class Set extends Object {
$item = $items[$token];
$matches[] = array(
'trace' => array_merge($context['trace'], $ctext),
'key' => $key,
'key' => $token,
'item' => $item,
);
break;

View file

@ -1027,6 +1027,20 @@ class SetTest extends CakeTestCase {
$expected = array('Second');
$this->assertEqual($result, $expected);
}
/**
* testExtractWithArrays method
*
* @access public
* @return void
*/
function testExtractWithArrays() {
$data = array(
'Level1' => array(
'Level2' => array('test1', 'test2'),
'Level2bis' => array('test3', 'test4')));
$this->assertEqual(Set::extract('/Level1/Level2', $data), array(array('Level2' => array('test1', 'test2'))));
$this->assertEqual(Set::extract('/Level1/Level2bis', $data), array(array('Level2bis' => array('test3', 'test4'))));
}
/**
* testMatches method
*
@ -1099,6 +1113,7 @@ class SetTest extends CakeTestCase {
}
/**
* testSetExtractReturnsEmptyArray method
*