xref: /PHP-5.4/ext/xmlwriter/tests/bug41326.phpt (revision 9324869e)
1--TEST--
2Bug #41287 (Writing empty tags with Xmlwriter::WriteElement[ns])
3--SKIPIF--
4<?php
5if (!extension_loaded("xmlwriter")) die("skip");
6?>
7--FILE--
8<?php
9$xml = new XmlWriter();
10$xml->openMemory();
11$xml->setIndent(true);
12$xml->startDocument();
13$xml->startElement('test');
14$xml->writeElement('foo', null);
15$xml->writeElement('foo2', "");
16$xml->writeElement('foo3');
17$xml->startElement('bar');
18$xml->endElement('bar');
19$xml->endElement();
20$xml->endElement();
21print $xml->flush(true);
22
23print "\n";
24
25$xw = new XMLWriter();
26$xw->openMemory();
27$xw->setIndent(true);
28$xw->startDocument();
29$xw->startElementNS('test', 'test', 'urn:x-test:');
30$xw->writeElementNS('test', 'foo', null, '');
31$xw->writeElementNS(null, 'bar', 'urn:x-test:', '');
32$xw->writeElementNS(null, 'bar', 'urn:x-test:', NULL);
33$xw->writeElementNS(null, 'bar', 'urn:x-test:');
34$xw->writeElementNS(null, 'bar', '', '');
35$xw->endElement();
36$xw->endDocument();
37print $xw->flush(true);
38?>
39--EXPECTF--
40Warning: XMLWriter::endElement() expects exactly 0 parameters, 1 given in %s on line %d
41<?xml version="1.0"?>
42<test>
43 <foo/>
44 <foo2></foo2>
45 <foo3/>
46 <bar/>
47</test>
48
49<?xml version="1.0"?>
50<test:test xmlns:test="urn:x-test:">
51 <test:foo></test:foo>
52 <bar xmlns="urn:x-test:"></bar>
53 <bar xmlns="urn:x-test:"/>
54 <bar xmlns="urn:x-test:"/>
55 <bar xmlns=""></bar>
56</test:test>
57