Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed a bug in Set::extract. Wrong key returned when two arrays are a…

…t the extraction level.

Signed-off-by: Mark Story <mark@mark-story.com>
  • Loading branch information...
commit bdfb50e6bb72cb95bd96dfe143335bf63a109142 1 parent 4ac2996
@real34 real34 authored markstory committed
Showing with 16 additions and 1 deletion.
  1. +1 −1  cake/libs/set.php
  2. +15 −0 cake/tests/cases/libs/set.test.php
View
2  cake/libs/set.php
@@ -454,7 +454,7 @@ function extract($path, $data = null, $options = array()) {
$item = $items[$token];
$matches[] = array(
'trace' => array_merge($context['trace'], $ctext),
- 'key' => $key,
+ 'key' => $token,
'item' => $item,
);
break;
View
15 cake/tests/cases/libs/set.test.php
@@ -1028,6 +1028,20 @@ function testExtract() {
$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
*
* @access public
@@ -1099,6 +1113,7 @@ function testMatches() {
}
+
/**
* testSetExtractReturnsEmptyArray method
*
Please sign in to comment.
Something went wrong with that request. Please try again.