Skip to content

Commit 53538b4

Browse files
committed
Got both dump and tree to 90% coverage
1 parent 3cad264 commit 53538b4

2 files changed

Lines changed: 149 additions & 1 deletion

File tree

tests/simplexml_dump_Test.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function setUp()
3535
]
3636
";
3737

38-
3938
$this->expected_named_NS = "SimpleXML object (1 item)
4039
[
4140
Element {

tests/simplexml_tree_Test.php

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<?php
2+
3+
class simplexml_tree_Test extends simplexml_dump_bootstrap
4+
{
5+
public function setUp()
6+
{
7+
$this->expected = "SimpleXML object (1 item)
8+
[0] // <movies>
9+
->movie[0]
10+
->title[0]
11+
->characters[0]
12+
->character[0]
13+
->name[0]
14+
->actor[0]
15+
->character[1]
16+
->name[0]
17+
->actor[0]
18+
->plot[0]
19+
->great-lines[0]
20+
->line[0]
21+
->rating[0]
22+
['type']
23+
->rating[1]
24+
['type']
25+
";
26+
27+
$this->expected_default_NS = "SimpleXML object (1 item)
28+
[0] // <movies>
29+
->movie[0]
30+
->title[0]
31+
->characters[0]
32+
->character[0]
33+
->name[0]
34+
->actor[0]
35+
->character[1]
36+
->name[0]
37+
->actor[0]
38+
->plot[0]
39+
->great-lines[0]
40+
->line[0]
41+
->rating[0]
42+
['type']
43+
->rating[1]
44+
['type']
45+
";
46+
47+
$this->expected_named_NS = "SimpleXML object (1 item)
48+
[0] // <movies>
49+
->children('test', true)
50+
->movie[0]
51+
->title[0]
52+
->characters[0]
53+
->character[0]
54+
->name[0]
55+
->actor[0]
56+
->character[1]
57+
->name[0]
58+
->actor[0]
59+
->plot[0]
60+
->great-lines[0]
61+
->line[0]
62+
->rating[0]
63+
->attributes('', true)
64+
->type
65+
->rating[1]
66+
->attributes('', true)
67+
->type
68+
";
69+
70+
parent::setUp();
71+
}
72+
73+
public function testTree()
74+
{
75+
ob_start();
76+
simplexml_tree($this->simpleXML);
77+
$return = ob_get_contents();
78+
ob_end_clean();
79+
80+
$this->assertEquals($this->expected, $return);
81+
}
82+
83+
public function testTreeIncludeStringContent()
84+
{
85+
ob_start();
86+
simplexml_tree($this->simpleXML, true);
87+
$return = ob_get_contents();
88+
ob_end_clean();
89+
90+
$expected = "SimpleXML object (1 item)
91+
[0] // <movies>
92+
(string) '' (9 chars)
93+
->movie[0]
94+
(string) '' (41 chars)
95+
->title[0]
96+
(string) 'PHP: Behind the...' (22 chars)
97+
->characters[0]
98+
(string) '' (20 chars)
99+
->character[0]
100+
(string) '' (23 chars)
101+
->name[0]
102+
(string) 'Ms. Coder' (9 chars)
103+
->actor[0]
104+
(string) 'Onlivia Actora' (14 chars)
105+
->character[1]
106+
(string) '' (23 chars)
107+
->name[0]
108+
(string) 'Mr. Coder' (9 chars)
109+
->actor[0]
110+
(string) 'El ActÓr' (9 chars)
111+
->plot[0]
112+
(string) 'So, this langua...' (174 chars)
113+
->great-lines[0]
114+
(string) '' (13 chars)
115+
->line[0]
116+
(string) 'PHP solves all ...' (30 chars)
117+
->rating[0]
118+
(string) '7' (1 chars)
119+
['type']
120+
(string) 'thumbs' (6 chars)
121+
->rating[1]
122+
(string) '5' (1 chars)
123+
['type']
124+
(string) 'stars' (5 chars)
125+
";
126+
127+
$this->assertEquals($expected, $return);
128+
}
129+
130+
public function testTreeReturn()
131+
{
132+
$return = simplexml_tree($this->simpleXML, false, true);
133+
$this->assertEquals($this->expected, $return);
134+
}
135+
136+
public function testTreeWithDefaultNS()
137+
{
138+
$return = simplexml_tree($this->simpleXML_default_NS, false, true);
139+
$this->assertEquals($this->expected_default_NS, $return);
140+
}
141+
142+
public function testTreeWithNamedNS()
143+
{
144+
$return = simplexml_tree($this->simpleXML_named_NS, false, true);
145+
$this->assertEquals($this->expected_named_NS, $return);
146+
}
147+
}
148+
149+
?>

0 commit comments

Comments
 (0)