Skip to content

Commit 1a3a674

Browse files
cmb69weltling
authored andcommitted
added failing tests for bug #62639, bug #67116, bug #69169 and bug #69491
1 parent bcd5853 commit 1a3a674

File tree

4 files changed

+246
-0
lines changed

4 files changed

+246
-0
lines changed

ext/simplexml/tests/bug62639.phpt

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
--TEST--
2+
Bug #62639 (XML structure broken)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6+
?>
7+
--FILE--
8+
<?php
9+
10+
class A extends SimpleXMLElement
11+
{
12+
}
13+
14+
$xml1 = <<<XML
15+
<?xml version="1.0"?>
16+
<a>
17+
<b>
18+
<c>
19+
<value attr="Some Attr">Some Value</value>
20+
</c>
21+
</b>
22+
</a>
23+
XML;
24+
25+
$a1 = new A($xml1);
26+
27+
foreach ($a1->b->c->children() as $key => $value) {
28+
var_dump($value);
29+
}
30+
31+
$xml2 = <<<XML
32+
<?xml version="1.0"?>
33+
<a>
34+
<b>
35+
<c><value attr="Some Attr">Some Value</value></c>
36+
</b>
37+
</a>
38+
XML;
39+
40+
$a2 = new A($xml2);
41+
42+
foreach ($a2->b->c->children() as $key => $value) {
43+
var_dump($value);
44+
}?>
45+
--EXPECT--
46+
object(A)#2 (2) {
47+
["@attributes"]=>
48+
array(1) {
49+
["attr"]=>
50+
string(9) "Some Attr"
51+
}
52+
[0]=>
53+
string(10) "Some Value"
54+
}
55+
object(A)#3 (2) {
56+
["@attributes"]=>
57+
array(1) {
58+
["attr"]=>
59+
string(9) "Some Attr"
60+
}
61+
[0]=>
62+
string(10) "Some Value"
63+
}

ext/simplexml/tests/bug67116.phpt

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
--TEST--
2+
Bug #67116 (Inconsistent parsing of Nodes w/o linefeed)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6+
?>
7+
--FILE--
8+
<?php
9+
10+
$xml = <<<XML
11+
<?xml version="1.0" encoding="UTF-8"?>
12+
<aa>
13+
<bs>
14+
<b>b</b>
15+
</bs>
16+
<cs><c>b</c></cs>
17+
<ds><d id="d"></d></ds>
18+
<es>
19+
<e id="e"></e>
20+
</es>
21+
<fs><f id="f"></f><f id="f"></f></fs>
22+
</aa>
23+
XML;
24+
$sxe = simplexml_load_string($xml);
25+
print_r($sxe);
26+
27+
?>
28+
--EXPECT--
29+
SimpleXMLElement Object
30+
(
31+
[bs] => SimpleXMLElement Object
32+
(
33+
[b] => b
34+
)
35+
36+
[cs] => SimpleXMLElement Object
37+
(
38+
[c] => b
39+
)
40+
41+
[ds] => SimpleXMLElement Object
42+
(
43+
[d] => SimpleXMLElement Object
44+
(
45+
[@attributes] => Array
46+
(
47+
[id] => d
48+
)
49+
50+
)
51+
52+
)
53+
54+
[es] => SimpleXMLElement Object
55+
(
56+
[e] => SimpleXMLElement Object
57+
(
58+
[@attributes] => Array
59+
(
60+
[id] => e
61+
)
62+
63+
)
64+
65+
)
66+
67+
[fs] => SimpleXMLElement Object
68+
(
69+
[f] => Array
70+
(
71+
[0] => SimpleXMLElement Object
72+
(
73+
[@attributes] => Array
74+
(
75+
[id] => f
76+
)
77+
78+
)
79+
80+
[1] => SimpleXMLElement Object
81+
(
82+
[@attributes] => Array
83+
(
84+
[id] => f
85+
)
86+
87+
)
88+
89+
)
90+
91+
)
92+
93+
)

ext/simplexml/tests/bug69169.phpt

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
--TEST--
2+
Bug #69169 (simplexml_load_string parse wrongly when xml given in one row)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6+
?>
7+
--FILE--
8+
<?php
9+
$a = '<?xml version="1.0" encoding="UTF-8"?>
10+
<root a="b">
11+
<row b="y">
12+
<item s="t" />
13+
</row>
14+
<row p="c">
15+
<item y="n" />
16+
</row>
17+
</root>';
18+
$b = str_replace(array("\n", "\r", "\t"), "", $a);
19+
$simple_xml = simplexml_load_string($b);
20+
print_r($simple_xml);
21+
?>
22+
--EXPECT--
23+
SimpleXMLElement Object
24+
(
25+
[@attributes] => Array
26+
(
27+
[a] => b
28+
)
29+
30+
[row] => Array
31+
(
32+
[0] => SimpleXMLElement Object
33+
(
34+
[@attributes] => Array
35+
(
36+
[b] => y
37+
)
38+
39+
[item] => SimpleXMLElement Object
40+
(
41+
[@attributes] => Array
42+
(
43+
[s] => t
44+
)
45+
46+
)
47+
48+
)
49+
50+
[1] => SimpleXMLElement Object
51+
(
52+
[@attributes] => Array
53+
(
54+
[p] => c
55+
)
56+
57+
[item] => SimpleXMLElement Object
58+
(
59+
[@attributes] => Array
60+
(
61+
[y] => n
62+
)
63+
64+
)
65+
66+
)
67+
68+
)
69+
70+
)

ext/simplexml/tests/bug69491.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #69491 (simplexml doesn't correctly parse empty nodes on same line as another node)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6+
?>
7+
--FILE--
8+
<?php
9+
var_dump(simplexml_load_string('<a>
10+
<b><c/></b>
11+
</a>'));?>
12+
--EXPECT--
13+
object(SimpleXMLElement)#1 (1) {
14+
["b"]=>
15+
object(SimpleXMLElement)#2 (1) {
16+
["c"]=>
17+
object(SimpleXMLElement)#3 (0) {
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)