xref: /PHP-7.2/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/* $Id$ */
8
9$doc_dest = '001.xml';
10$xw = xmlwriter_open_uri($doc_dest);
11xmlwriter_start_document($xw, '1.0', 'UTF-8');
12xmlwriter_start_element($xw, "tag1");
13
14xmlwriter_start_pi($xw, "PHP");
15xmlwriter_text($xw, 'echo $a;');
16xmlwriter_end_pi($xw);
17xmlwriter_end_document($xw);
18
19// Force to write and empty the buffer
20$output_bytes = xmlwriter_flush($xw, true);
21$md5_out = md5_file($doc_dest);
22$md5_res = md5('<?xml version="1.0" encoding="UTF-8"?>
23<tag1><?PHP echo $a;?></tag1>
24');
25unset($xw);
26unlink('001.xml');
27if ($md5_out != $md5_res) {
28	echo "failed: $md5_res != $md5_out\n";
29} else {
30	echo "ok.\n";
31}
32?>
33===DONE===
34--EXPECT--
35ok.
36===DONE===
37