Skip to content

Commit d7f2798

Browse files
committed
Merge branch 'pull-request/757' into PHP-5.5
* pull-request/757: xmlwriter_full_end_element tests Tests for writeAttributeNS and xmlwriter_write_attribute_ns
2 parents 711a3ab + 8afe869 commit d7f2798

File tree

4 files changed

+148
-0
lines changed

4 files changed

+148
-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/012.phpt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
XMLWriter: libxml2 XML Writer, full_end_element 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_start_element($xw, 'empty');
25+
xmlwriter_full_end_element($xw);
26+
xmlwriter_full_end_element($xw);
27+
// Force to write and empty the buffer
28+
$output = xmlwriter_flush($xw, true);
29+
print $output;
30+
?>
31+
--EXPECT--
32+
<?xml version="1.0" encoding="UTF-8"?>
33+
<root>
34+
<ns1:child1 ns1:att1="&lt;&gt;&quot;'&amp;" xmlns:ns1="urn:ns1">
35+
<chars>special characters: &lt;&gt;&quot;'&amp;</chars>
36+
</ns1:child1>
37+
<empty></empty>
38+
</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>

ext/xmlwriter/tests/OO_011.phpt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
XMLWriter: libxml2 XML Writer, fullEndElement 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->startElement('empty');
26+
$xw->fullEndElement();
27+
$xw->fullEndElement();
28+
// Force to write and empty the buffer
29+
$output = $xw->flush(true);
30+
print $output;
31+
?>
32+
--EXPECT--
33+
<?xml version="1.0" encoding="UTF-8"?>
34+
<root>
35+
<ns1:child1 ns1:att1="&lt;&gt;&quot;'&amp;" xmlns:ns1="urn:ns1">
36+
<chars>special characters: &lt;&gt;&quot;'&amp;</chars>
37+
</ns1:child1>
38+
<empty></empty>
39+
</root>

0 commit comments

Comments
 (0)