xref: /PHP-8.3/ext/xmlwriter/tests/bug41287.phpt (revision 74859783)
1--TEST--
2Bug #41287 (Namespace functions don't allow xmlns definition to be optional)
3--EXTENSIONS--
4xmlwriter
5--FILE--
6<?php
7
8$xw = xmlwriter_open_memory();
9xmlwriter_set_indent($xw, true);
10xmlwriter_start_document($xw);
11xmlwriter_start_element_ns($xw, 'test', 'test', 'urn:x-test:');
12xmlwriter_write_element_ns($xw, 'test', 'foo', null, '');
13xmlwriter_write_element_ns($xw, null, 'bar', 'urn:x-test:', '');
14xmlwriter_write_element_ns($xw, null, 'bar', '', '');
15xmlwriter_end_element($xw);
16xmlwriter_end_document($xw);
17print xmlwriter_flush($xw, true);
18print "\n";
19
20$xw = new XMLWriter();
21$xw->openMemory();
22$xw->setIndent(true);
23$xw->startDocument();
24$xw->startElementNS('test', 'test', 'urn:x-test:');
25$xw->writeElementNS('test', 'foo', null, '');
26$xw->writeElementNS(null, 'bar', 'urn:x-test:', '');
27$xw->writeElementNS(null, 'bar', '', '');
28$xw->endElement();
29$xw->endDocument();
30print $xw->flush(true);
31?>
32--EXPECT--
33<?xml version="1.0"?>
34<test:test xmlns:test="urn:x-test:">
35 <test:foo></test:foo>
36 <bar xmlns="urn:x-test:"></bar>
37 <bar xmlns=""></bar>
38</test:test>
39
40<?xml version="1.0"?>
41<test:test xmlns:test="urn:x-test:">
42 <test:foo></test:foo>
43 <bar xmlns="urn:x-test:"></bar>
44 <bar xmlns=""></bar>
45</test:test>
46