Skip to content

Commit 51be35c

Browse files
mauriciovieirarogeriopradoj
authored andcommitted
Tests for writeAttributeNS and xmlwriter_write_attribute_ns
1 parent 95febf2 commit 51be35c

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

ext/xmlwriter/tests/011.phpt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
XMLWriter: libxml2 XML Writer, write_attribute_ns function
3+
--CREDITS--
4+
Mauricio Vieira <mauricio [at] @mauriciovieira [dot] net>
5+
#testfest PHPSP on 2014-07-05
6+
--SKIPIF--
7+
<?php
8+
if (!extension_loaded("xmlwriter")) die("skip");
9+
if (LIBXML_VERSION < 20617) die("skip: libxml2 2.6.17+ required");
10+
?>
11+
--FILE--
12+
<?php
13+
/* $Id$ */
14+
15+
$xw = xmlwriter_open_memory();
16+
xmlwriter_set_indent($xw, TRUE);
17+
xmlwriter_set_indent_string($xw, ' ');
18+
xmlwriter_start_document($xw, '1.0', "UTF-8");
19+
xmlwriter_start_element($xw, 'root');
20+
xmlwriter_start_element_ns($xw, 'ns1', 'child1', 'urn:ns1');
21+
xmlwriter_write_attribute_ns($xw, 'ns1','att1', 'urn:ns1', '<>"\'&');
22+
xmlwriter_write_element($xw, 'chars', "special characters: <>\"'&");
23+
xmlwriter_end_element($xw);
24+
xmlwriter_end_document($xw);
25+
// Force to write and empty the buffer
26+
$output = xmlwriter_flush($xw, true);
27+
print $output;
28+
?>
29+
--EXPECT--
30+
<?xml version="1.0" encoding="UTF-8"?>
31+
<root>
32+
<ns1:child1 ns1:att1="&lt;&gt;&quot;'&amp;" xmlns:ns1="urn:ns1">
33+
<chars>special characters: &lt;&gt;&quot;'&amp;</chars>
34+
</ns1:child1>
35+
</root>

ext/xmlwriter/tests/OO_010.phpt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
XMLWriter: libxml2 XML Writer, writeAttributeNS method
3+
--CREDITS--
4+
Mauricio Vieira <mauricio [at] @mauriciovieira [dot] net>
5+
#testfest PHPSP on 2014-07-05
6+
--SKIPIF--
7+
<?php
8+
if (!extension_loaded("xmlwriter")) die("skip");
9+
if (LIBXML_VERSION < 20617) die("skip: libxml2 2.6.17+ required");
10+
?>
11+
--FILE--
12+
<?php
13+
/* $Id$ */
14+
15+
$xw = new XMLWriter();
16+
$xw->openMemory();
17+
$xw->setIndent(TRUE);
18+
$xw->setIndentString(' ');
19+
$xw->startDocument('1.0', "UTF-8");
20+
$xw->startElement('root');
21+
$xw->startElementNS('ns1', 'child1', 'urn:ns1');
22+
$xw->writeAttributeNS('ns1', 'att1', 'urn:ns1', '<>"\'&');
23+
$xw->writeElement('chars', "special characters: <>\"'&");
24+
$xw->endElement();
25+
$xw->endDocument();
26+
// Force to write and empty the buffer
27+
$output = $xw->flush(true);
28+
print $output;
29+
?>
30+
--EXPECT--
31+
<?xml version="1.0" encoding="UTF-8"?>
32+
<root>
33+
<ns1:child1 ns1:att1="&lt;&gt;&quot;'&amp;" xmlns:ns1="urn:ns1">
34+
<chars>special characters: &lt;&gt;&quot;'&amp;</chars>
35+
</ns1:child1>
36+
</root>

0 commit comments

Comments
 (0)