xref: /PHP-7.0/ext/xmlwriter/tests/OO_004.phpt (revision bcd9356d)
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 = new XMLWriter();
11$xw->openUri($doc_dest);
12$xw->startDocument('1.0', 'UTF-8');
13$xw->startElement("tag1");
14
15$xw->startPi("PHP");
16$xw->text('echo $a;');
17$xw->endPi();
18$xw->endDocument();
19
20// Force to write and empty the buffer
21$xw->flush(true);
22$md5_out = md5_file($doc_dest);
23$md5_res = md5('<?xml version="1.0" encoding="UTF-8"?>
24<tag1><?PHP echo $a;?></tag1>
25');
26unset($xw);
27unlink('001.xml');
28if ($md5_out != $md5_res) {
29	echo "failed: $md5_res != $md5_out\n";
30} else {
31	echo "ok.\n";
32}
33?>
34===DONE===
35--EXPECT--
36ok.
37===DONE===
38