File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ class XmlToArrayTest extends TestCase
4+ {
5+ /** @test */
6+ public function it_transforms_xml_string_to_array ()
7+ {
8+ $ xml = file_get_contents (__DIR__ . '/XmlToArrayTest/example.xml ' );
9+
10+ $ expected = [
11+ 'tasks ' => [
12+ 'task ' => [
13+ 0 => [
14+ 'to ' => 'John ' ,
15+ 'from ' => 'Jane ' ,
16+ 'title ' => 'Go to the shop ' ,
17+ ],
18+ 1 => [
19+ 'to ' => 'John ' ,
20+ 'from ' => 'Paul ' ,
21+ 'title ' => 'Finish the report ' ,
22+ ],
23+ 2 => [
24+ 'to ' => 'Jane ' ,
25+ 'from ' => 'Jeff ' ,
26+ 'title ' => 'Clean the house ' ,
27+ ],
28+ ],
29+ ],
30+ ];
31+
32+ $ this ->assertEquals ($ expected , xml_to_array ($ xml ));
33+ }
34+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <root >
3+ <tasks >
4+ <task >
5+ <to >John</to >
6+ <from >Jane</from >
7+ <title >Go to the shop</title >
8+ </task >
9+ <task >
10+ <to >John</to >
11+ <from >Paul</from >
12+ <title >Finish the report</title >
13+ </task >
14+ <task >
15+ <to >Jane</to >
16+ <from >Jeff</from >
17+ <title >Clean the house</title >
18+ </task >
19+ </tasks >
20+ </root >
You can’t perform that action at this time.
0 commit comments