Skip to content

Commit 8e5b906

Browse files
cmb69weltling
authored andcommitted
added tests for bug #61335, bug #67572 and bug #68946 (the latter already passing, but better safe than sorry)
1 parent db4a6de commit 8e5b906

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

ext/simplexml/tests/bug61335.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Bug #61335 - Access to array node returns wrong truth value
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6+
?>
7+
--FILE--
8+
<?php
9+
$rec1 = simplexml_load_string("<foo><bar>aa</bar>\n</foo>");
10+
$rec2 = simplexml_load_string("<foo><bar>aa</bar></foo>");
11+
12+
if ($rec1->bar[0]) echo "NONEMPTY1\n";
13+
if ($rec1->bar[0] . "") echo "NONEMPTY2\n";
14+
if ($rec2->bar[0]) echo "NONEMPTY3\n";
15+
?>
16+
--EXPECT--
17+
NONEMPTY1
18+
NONEMPTY2
19+
NONEMPTY3

ext/simplexml/tests/bug67572.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug #67572 - SimpleXMLElement not parsing \n correctly
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6+
?>
7+
--FILE--
8+
<?php
9+
$foo = 'bar';
10+
print "regular string ... ";
11+
var_dump(empty($foo));
12+
13+
$xml = simplexml_load_string("<xml><something>somevalue</something></xml>");
14+
$xml2 = simplexml_load_string("<xml>\n<something>somevalue</something>\n</xml>");
15+
16+
foreach($xml as $key => $value) {
17+
print "$key = $value ... ";
18+
var_dump(empty($value));
19+
var_dump($value == false);
20+
}
21+
22+
foreach($xml2 as $key => $value) {
23+
print "$key = $value ... ";
24+
var_dump(empty($value));
25+
var_dump($value == false);
26+
}
27+
?>
28+
--EXPECT--
29+
regular string ... bool(false)
30+
something = somevalue ... bool(false)
31+
bool(false)
32+
something = somevalue ... bool(false)
33+
bool(false)

ext/simplexml/tests/bug68946.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #68946 - simplexml_load_string() result depends on formatting of xml string
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6+
?>
7+
--FILE--
8+
<?php
9+
$sxe = simplexml_load_string("<?BrightCloud version=bcap/1.1?><bcap><seqnum>1</seqnum></bcap>");
10+
var_dump($sxe == false);
11+
$sxe = simplexml_load_string("<?BrightCloud version=bcap/1.1?><bcap> <seqnum>1</seqnum></bcap>");
12+
var_dump($sxe == false);
13+
?>
14+
--EXPECT--
15+
bool(false)
16+
bool(false)

0 commit comments

Comments
 (0)