Skip to content

Commit d5e51fc

Browse files
symeonnikic
authored andcommitted
Test xml_error_string() and xml_get_error_code()
Closes GH-5456.
1 parent 1baa583 commit d5e51fc

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
xml_error_string() - Basic test on 5 error codes
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('xml')) {
6+
exit('Skip - XML extension not loaded');
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
$xmls = array(
12+
'<?xml version="1.0"?><element>',
13+
'<?xml>',
14+
'<?xml version="dummy">',
15+
'<?xml?>',
16+
'<?xml version="1.0"?><elem></element>',
17+
);
18+
19+
foreach ($xmls as $xml) {
20+
$xml_parser = xml_parser_create();
21+
if (!xml_parse($xml_parser, $xml, true)) {
22+
var_dump(xml_get_error_code($xml_parser));
23+
var_dump(xml_error_string(xml_get_error_code($xml_parser)));
24+
}
25+
xml_parser_free($xml_parser);
26+
}
27+
?>
28+
--EXPECT--
29+
int(5)
30+
string(20) "Invalid document end"
31+
int(47)
32+
string(35) "Processing Instruction not finished"
33+
int(57)
34+
string(28) "XML declaration not finished"
35+
int(64)
36+
string(17) "Reserved XML Name"
37+
int(76)
38+
string(14) "Mismatched tag"

0 commit comments

Comments
 (0)