Skip to content

Commit c7a8e41

Browse files
committed
IHF: xml_to_array tests added.
1 parent 160f165 commit c7a8e41

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/xml/XmlToArrayTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,34 @@ public function it_transforms_xml_string_to_array()
3131

3232
$this->assertEquals($expected, xml_to_array($xml));
3333
}
34+
35+
/** @test */
36+
public function it_also_allows_to_pass_simplexmlelement_object()
37+
{
38+
$xml = new SimpleXMLElement(file_get_contents(__DIR__ . '/XmlToArrayTest/example.xml'));
39+
40+
$expected = [
41+
'tasks' => [
42+
'task' => [
43+
0 => [
44+
'to' => 'John',
45+
'from' => 'Jane',
46+
'title' => 'Go to the shop',
47+
],
48+
1 => [
49+
'to' => 'John',
50+
'from' => 'Paul',
51+
'title' => 'Finish the report',
52+
],
53+
2 => [
54+
'to' => 'Jane',
55+
'from' => 'Jeff',
56+
'title' => 'Clean the house',
57+
],
58+
],
59+
],
60+
];
61+
62+
$this->assertEquals($expected, xml_to_array($xml));
63+
}
3464
}

0 commit comments

Comments
 (0)