@@ -18,7 +18,25 @@ public function setUp()
1818]
1919 " ;
2020
21- $ this ->expected_NS = "SimpleXML object (1 item)
21+ $ this ->expected_default_NS = "SimpleXML object (1 item)
22+ [
23+ Element {
24+ Namespace: 'https://github.com/IMSoP/simplexml_debug'
25+ (Default Namespace)
26+ Name: 'movies'
27+ String Content: '
28+
29+ '
30+ Content in Default Namespace
31+ Namespace URI: 'https://github.com/IMSoP/simplexml_debug'
32+ Children: 1 - 1 'movie'
33+ Attributes: 0
34+ }
35+ ]
36+ " ;
37+
38+
39+ $ this ->expected_named_NS = "SimpleXML object (1 item)
2240[
2341 Element {
2442 Name: 'movies'
@@ -52,13 +70,19 @@ public function testDumpReturn()
5270 $ this ->assertEquals ($ this ->expected , $ return );
5371 }
5472
55- public function testDumpWithNS ()
73+ public function testDumpWithDefaultNS ()
74+ {
75+ $ return = simplexml_dump ($ this ->simpleXML_default_NS , true );
76+ $ this ->assertEquals ($ this ->expected_default_NS , $ return );
77+ }
78+
79+ public function testDumpWithNamedNS ()
5680 {
57- $ return = simplexml_dump ($ this ->simpleXML_NS , true );
58- $ this ->assertEquals ($ this ->expected_NS , $ return );
81+ $ return = simplexml_dump ($ this ->simpleXML_named_NS , true );
82+ $ this ->assertEquals ($ this ->expected_named_NS , $ return );
5983 }
6084
61- public function testDumpWithSingleNodeWithAttributesAndNS ()
85+ public function testDumpAttributeWithNamedNS ()
6286 {
6387 $ xml = '<parent xmlns:ns="ns"><ns:child ns:foo="bar" /></parent> ' ;
6488 $ sxml = simplexml_load_string ($ xml );
@@ -74,6 +98,31 @@ public function testDumpWithSingleNodeWithAttributesAndNS()
7498 Value: 'bar'
7599 }
76100]
101+ " ;
102+
103+ $ this ->assertEquals ($ expected , $ return );
104+ }
105+
106+ public function testDumpMultipleAttributes ()
107+ {
108+ $ xml = '<parent xmlns:ns="ns"><child ns:one="1" ns:two="2" ns:three="3" /></parent> ' ;
109+ $ sxml = simplexml_load_string ($ xml );
110+
111+ $ return = simplexml_dump ($ sxml ->child , true );
112+
113+ $ expected = "SimpleXML object (1 item)
114+ [
115+ Element {
116+ Namespace: 'ns'
117+ Namespace Alias: 'ns'
118+ Name: 'child'
119+ String Content: ''
120+ Content in Namespace ns
121+ Namespace URI: 'ns'
122+ Children: 0
123+ Attributes: 3 - 'one', 'two', 'three'
124+ }
125+ ]
77126 " ;
78127
79128 $ this ->assertEquals ($ expected , $ return );
0 commit comments