Skip to content

Commit e23830d

Browse files
committed
fixed multi-attach value
1 parent 5814430 commit e23830d

File tree

2 files changed

+43
-14
lines changed

2 files changed

+43
-14
lines changed

src/Xml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public static function convertSimpleXml($xml)
225225
$subRowItem = self::convertSimpleXmlItem($childItem);
226226
$children = $childItem->children();
227227
if(!empty((array)$children)) {
228-
$subRowItem['value'] = self::convertSimpleXmlItem($children);
228+
$subRowItem['value'] = self::convertSimpleXml($children);
229229
}
230230
if(empty($rowItem['value'])) {
231231
$rowItem['value'] = [];

tests/unit/XmlTest.php

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,24 @@ class XmlTest extends \Codeception\Test\Unit
4747
],
4848
],
4949
],
50-
]
50+
],
51+
'mlp' => [
52+
[
53+
'value' => [
54+
'sub1' => [
55+
[
56+
'value' => [
57+
'sub2' => [
58+
[
59+
'value' => 'val'
60+
]
61+
]
62+
],
63+
],
64+
],
65+
],
66+
],
67+
],
5168
];
5269

5370
protected $resultArray = [
@@ -101,7 +118,24 @@ class XmlTest extends \Codeception\Test\Unit
101118
],
102119
],
103120
]
104-
]
121+
],
122+
'mlp' => [
123+
[
124+
'value' => [
125+
'sub1' => [
126+
[
127+
'value' => [
128+
'sub2' => [
129+
[
130+
'value' => 'val'
131+
]
132+
]
133+
],
134+
],
135+
],
136+
],
137+
],
138+
],
105139
];
106140

107141
protected $xml = '<?xml version="1.0" encoding="utf-8"?>
@@ -117,20 +151,15 @@ protected function _after()
117151
{
118152
}
119153

120-
// public function testEncodeXml()
121-
// {
122-
//
123-
// $xml = \darkfriend\helpers\Xml::encode($this->encodeArray);
124-
//
125-
// $this->assertEquals($xml, $this->xml);
126-
// }
154+
public function testEncodeXml()
155+
{
156+
$xml = \darkfriend\helpers\Xml::encode($this->encodeArray);
157+
158+
$this->assertEquals($xml, $this->xml);
159+
}
127160

128161
public function testDecodeXml()
129162
{
130-
// var_dump($this->resultArray);
131-
var_dump(\darkfriend\helpers\Xml::decode($this->xml));
132-
die();
133-
134163
$this->assertTrue(
135164
\darkfriend\helpers\Xml::decode($this->xml) === $this->resultArray
136165
);

0 commit comments

Comments
 (0)