mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Test xml_error_string() and xml_get_error_code()
Closes GH-5456.
This commit is contained in:
parent
1baa58317f
commit
d5e51fc186
1 changed files with 38 additions and 0 deletions
38
ext/xml/tests/xml_error_string_basic.phpt
Normal file
38
ext/xml/tests/xml_error_string_basic.phpt
Normal file
|
@ -0,0 +1,38 @@
|
|||
--TEST--
|
||||
xml_error_string() - Basic test on 5 error codes
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('xml')) {
|
||||
exit('Skip - XML extension not loaded');
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$xmls = array(
|
||||
'<?xml version="1.0"?><element>',
|
||||
'<?xml>',
|
||||
'<?xml version="dummy">',
|
||||
'<?xml?>',
|
||||
'<?xml version="1.0"?><elem></element>',
|
||||
);
|
||||
|
||||
foreach ($xmls as $xml) {
|
||||
$xml_parser = xml_parser_create();
|
||||
if (!xml_parse($xml_parser, $xml, true)) {
|
||||
var_dump(xml_get_error_code($xml_parser));
|
||||
var_dump(xml_error_string(xml_get_error_code($xml_parser)));
|
||||
}
|
||||
xml_parser_free($xml_parser);
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
int(5)
|
||||
string(20) "Invalid document end"
|
||||
int(47)
|
||||
string(35) "Processing Instruction not finished"
|
||||
int(57)
|
||||
string(28) "XML declaration not finished"
|
||||
int(64)
|
||||
string(17) "Reserved XML Name"
|
||||
int(76)
|
||||
string(14) "Mismatched tag"
|
Loading…
Add table
Add a link
Reference in a new issue