xref: /php-src/ext/xml/tests/bug81351.phpt (revision 552ea62e)
1--TEST--
2Bug #81351 (xml_parse may fail, but has no error code)
3--EXTENSIONS--
4xml
5--FILE--
6<?php
7$xml = <<<XML
8<?xml version="1.0" encoding="utf-8"?>
9<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
10 <soap:Body>
11  <X xmlns="example.org">
12XML;
13
14$parser = xml_parser_create_ns('UTF-8');
15$success = xml_parse($parser, $xml, false);
16$code = xml_get_error_code($parser);
17$error = xml_error_string($code);
18echo "xml_parse returned $success, xml_get_error_code = $code, xml_error_string = $error\r\n";
19$success = xml_parse($parser, 'Y>', true);
20$code = xml_get_error_code($parser);
21$error = xml_error_string($code);
22echo "xml_parse returned $success, xml_get_error_code = $code, xml_error_string = $error\r\n";
23?>
24--EXPECTF--
25xml_parse returned 1, xml_get_error_code = 0, xml_error_string = %S
26%rxml_parse returned 0, xml_get_error_code = 5, xml_error_string = Invalid document end|xml_parse returned 0, xml_get_error_code = 3, xml_error_string = no element found|xml_parse returned 0, xml_get_error_code = 77, xml_error_string = Tag not finished%r
27