Skip to content

Commit 8afe869

Browse files
mauriciovieirarogeriopradoj
authored andcommitted
xmlwriter_full_end_element tests
1 parent 51be35c commit 8afe869

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

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_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)