xref: /PHP-7.3/ext/xmlwriter/tests/004.phpt (revision 17ccbeec)
1--TEST--
2XMLWriter: libxml2 XML Writer, file buffer, flush
3--SKIPIF--
4<?php if (!extension_loaded("xmlwriter")) print "skip"; ?>
5--FILE--
6<?php
7
8$doc_dest = '001.xml';
9$xw = xmlwriter_open_uri($doc_dest);
10xmlwriter_start_document($xw, '1.0', 'UTF-8');
11xmlwriter_start_element($xw, "tag1");
12
13xmlwriter_start_pi($xw, "PHP");
14xmlwriter_text($xw, 'echo $a;');
15xmlwriter_end_pi($xw);
16xmlwriter_end_document($xw);
17
18// Force to write and empty the buffer
19$output_bytes = xmlwriter_flush($xw, true);
20$md5_out = md5_file($doc_dest);
21$md5_res = md5('<?xml version="1.0" encoding="UTF-8"?>
22<tag1><?PHP echo $a;?></tag1>
23');
24unset($xw);
25unlink('001.xml');
26if ($md5_out != $md5_res) {
27	echo "failed: $md5_res != $md5_out\n";
28} else {
29	echo "ok.\n";
30}
31?>
32===DONE===
33--EXPECT--
34ok.
35===DONE===
36