Skip to content

Commit d185cfc

Browse files
committed
IHF: array_to_xml helper tests added.
1 parent 9ff2eed commit d185cfc

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/xml/ArrayToXmlTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,32 @@ public function is_supports_xml_attributes_in_converting()
6666

6767
$this->assertEquals($expected, array_to_xml($array));
6868
}
69+
70+
/** @test */
71+
public function is_supports_custom_root_element_name()
72+
{
73+
$array = [
74+
'task' => [
75+
0 => [
76+
'to' => 'John',
77+
'from' => 'Jane',
78+
'title' => 'Go to the shop',
79+
],
80+
1 => [
81+
'to' => 'John',
82+
'from' => 'Paul',
83+
'title' => 'Finish the report',
84+
],
85+
2 => [
86+
'to' => 'Jane',
87+
'from' => 'Jeff',
88+
'title' => 'Clean the house',
89+
],
90+
],
91+
];
92+
93+
$expected = file_get_contents(__DIR__ . '/ArrayToXmlTest/with-custom-root.xml');
94+
95+
$this->assertEquals($expected, array_to_xml($array, 'tasks'));
96+
}
6997
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0"?>
2+
<tasks><task><to>John</to><from>Jane</from><title>Go to the shop</title></task><task><to>John</to><from>Paul</from><title>Finish the report</title></task><task><to>Jane</to><from>Jeff</from><title>Clean the house</title></task></tasks>

0 commit comments

Comments
 (0)