xref: /php-src/ext/xmlwriter/tests/bug41326.phpt (revision 74859783)
1--TEST--
2Bug #41287 (Writing empty tags with Xmlwriter::WriteElement[ns])
3--EXTENSIONS--
4xmlwriter
5--FILE--
6<?php
7$xml = new XmlWriter();
8$xml->openMemory();
9$xml->setIndent(true);
10$xml->startDocument();
11$xml->startElement('test');
12$xml->writeElement('foo', null);
13$xml->writeElement('foo2', "");
14$xml->writeElement('foo3');
15$xml->startElement('bar');
16$xml->endElement();
17$xml->endElement();
18print $xml->flush(true);
19
20print "\n";
21
22$xw = new XMLWriter();
23$xw->openMemory();
24$xw->setIndent(true);
25$xw->startDocument();
26$xw->startElementNS('test', 'test', 'urn:x-test:');
27$xw->writeElementNS('test', 'foo', null, '');
28$xw->writeElementNS(null, 'bar', 'urn:x-test:', '');
29$xw->writeElementNS(null, 'bar', 'urn:x-test:', NULL);
30$xw->writeElementNS(null, 'bar', 'urn:x-test:');
31$xw->writeElementNS(null, 'bar', '', '');
32$xw->endElement();
33$xw->endDocument();
34print $xw->flush(true);
35?>
36--EXPECT--
37<?xml version="1.0"?>
38<test>
39 <foo/>
40 <foo2></foo2>
41 <foo3/>
42 <bar/>
43</test>
44
45<?xml version="1.0"?>
46<test:test xmlns:test="urn:x-test:">
47 <test:foo></test:foo>
48 <bar xmlns="urn:x-test:"></bar>
49 <bar xmlns="urn:x-test:"/>
50 <bar xmlns="urn:x-test:"/>
51 <bar xmlns=""></bar>
52</test:test>
53