Fixed xml encoder test script, and group item
tags into an array
This commit is contained in:
parent
a0561e5dde
commit
c9a2b49eb7
@ -188,14 +188,11 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
|
||||
$value = (string) $subnode;
|
||||
}
|
||||
|
||||
if ($key === '*item') {
|
||||
if ($key === 'item') {
|
||||
if (isset($value['@key'])) {
|
||||
$data[(string) $value['@key']] = $value['#'];
|
||||
} elseif (isset($data['*item'])) {
|
||||
$tmp = $data['*item'];
|
||||
unset($data['*item']);
|
||||
$data[] = $tmp;
|
||||
$data[] = $value;
|
||||
} else {
|
||||
$data['item'][] = $value;
|
||||
}
|
||||
} elseif (array_key_exists($key, $data)) {
|
||||
if ((false === is_array($data[$key])) || (false === isset($data[$key][0]))) {
|
||||
|
@ -239,6 +239,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
|
||||
'<foo><![CDATA[foo]]></foo>'.
|
||||
'<bar><![CDATA[a]]></bar><bar><![CDATA[b]]></bar>'.
|
||||
'<baz><key><![CDATA[val]]></key><key2><![CDATA[val]]></key2><item key="A B"><![CDATA[bar]]></item>'.
|
||||
'<item><title><![CDATA[title1]]></title></item><item><title><![CDATA[title2]]></title></item>'.
|
||||
'<Barry><FooBar id="1"><Baz><![CDATA[Ed]]></Baz></FooBar></Barry></baz>'.
|
||||
'<qux>1</qux>'.
|
||||
'</response>'."\n";
|
||||
@ -249,7 +250,7 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase
|
||||
$obj = new Dummy;
|
||||
$obj->foo = 'foo';
|
||||
$obj->bar = array('a', 'b');
|
||||
$obj->baz = array('key' => 'val', 'key2' => 'val', 'A B' => 'bar', "Barry" => array('FooBar' => array("Baz"=>"Ed", "@id"=>1)));
|
||||
$obj->baz = array('key' => 'val', 'key2' => 'val', 'A B' => 'bar', 'item' => array(array('title' => 'title1'), array('title' => 'title2')), 'Barry' => array('FooBar' => array('Baz' => 'Ed', '@id' => 1)));
|
||||
$obj->qux = "1";
|
||||
|
||||
return $obj;
|
||||
|
Reference in New Issue
Block a user