xref: /PHP-5.6/ext/xmlwriter/tests/bug41287.phpt (revision e9a95d78)
1--TEST--
2Bug #41287 (Namespace functions don't allow xmlns definition to be optional)
3--SKIPIF--
4<?php
5if (!extension_loaded("xmlwriter")) die("skip");
6?>
7--FILE--
8<?php
9
10$xw = xmlwriter_open_memory();
11xmlwriter_set_indent($xw, true);
12xmlwriter_start_document($xw);
13xmlwriter_start_element_ns($xw, 'test', 'test', 'urn:x-test:');
14xmlwriter_write_element_ns($xw, 'test', 'foo', null, '');
15xmlwriter_write_element_ns($xw, null, 'bar', 'urn:x-test:', '');
16xmlwriter_write_element_ns($xw, null, 'bar', '', '');
17xmlwriter_end_element($xw);
18xmlwriter_end_document($xw);
19print xmlwriter_flush($xw, true);
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', '', '');
30$xw->endElement();
31$xw->endDocument();
32print $xw->flush(true);
33?>
34--EXPECTF--
35<?xml version="1.0"?>
36<test:test xmlns:test="urn:x-test:">
37 <test:foo></test:foo>
38 <bar xmlns="urn:x-test:"></bar>
39 <bar xmlns=""></bar>
40</test:test>
41
42<?xml version="1.0"?>
43<test:test xmlns:test="urn:x-test:">
44 <test:foo></test:foo>
45 <bar xmlns="urn:x-test:"></bar>
46 <bar xmlns=""></bar>
47</test:test>
48