fixes #5384, Xml::toArray()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7555 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-09-04 15:34:08 +00:00
parent ff7428e676
commit 2a84ec9944
2 changed files with 35 additions and 13 deletions

View file

@ -678,7 +678,7 @@ class XmlNode extends Object {
if ($child->attributes) {
$value = array_merge(array('value' => $value), $child->attributes);
}
if (isset($out[$child->name])) {
if (isset($out[$child->name]) || isset($multi[$key])) {
if (!isset($multi)) {
$multi = array($key => array($out[$child->name]));
unset($out[$child->name]);

View file

@ -862,6 +862,28 @@ class XmlTest extends CakeTestCase {
)
));
$this->assertEqual($result, $expected);
$text = "<?xml version='1.0' encoding='utf-8'?>
<course>
<comps>
<comp>1</comp>
<comp>2</comp>
<comp>3</comp>
<comp>4</comp>
</comps>
</course>";
$xml = new Xml($text);
$result = $xml->toArray();
$expected = array('Course' => array(
'Comps' => array(
'Comp' => array(
1, 2, 3, 4
)
)
));
$this->assertEqual($result, $expected);
}