xref: /PHP-7.4/ext/xmlwriter/tests/OO_004.phpt (revision 832b89d1)
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 = 'OO_004.xml';
9$xw = new XMLWriter();
10$xw->openUri($doc_dest);
11$xw->startDocument('1.0', 'UTF-8');
12$xw->startElement("tag1");
13
14$xw->startPi("PHP");
15$xw->text('echo $a;');
16$xw->endPi();
17$xw->endDocument();
18
19// Force to write and empty the buffer
20$xw->flush(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($doc_dest);
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