xref: /PHP-8.0/ext/xml/tests/bug81351.phpt (revision 80a377e6)
1--TEST--
2Bug #81351 (xml_parse may fail, but has no error code)
3--SKIPIF--
4<?php
5if (!extension_loaded('xml')) die("skip xml extension not available");
6?>
7--FILE--
8<?php
9$xml = <<<XML
10<?xml version="1.0" encoding="utf-8"?>
11<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">
12 <soap:Body>
13  <X xmlns="example.org">
14XML;
15
16$parser = xml_parser_create_ns('UTF-8');
17$success = xml_parse($parser, $xml, false);
18$code = xml_get_error_code($parser);
19$error = xml_error_string($code);
20echo "xml_parse returned $success, xml_get_error_code = $code, xml_error_string = $error\r\n";
21$success = xml_parse($parser, 'Y>', true);
22$code = xml_get_error_code($parser);
23$error = xml_error_string($code);
24echo "xml_parse returned $success, xml_get_error_code = $code, xml_error_string = $error\r\n";
25?>
26--EXPECT--
27xml_parse returned 1, xml_get_error_code = 0, xml_error_string = No error
28xml_parse returned 0, xml_get_error_code = 5, xml_error_string = Invalid document end
29