OO_004.phpt 714 B

12345678910111213141516171819202122232425262728293031323334353637
  1. --TEST--
  2. XMLWriter: libxml2 XML Writer, file buffer, flush
  3. --SKIPIF--
  4. <?php if (!extension_loaded("xmlwriter")) print "skip"; ?>
  5. --FILE--
  6. <?php
  7. /* $Id$ */
  8. $doc_dest = '001.xml';
  9. $xw = new XMLWriter();
  10. $xw->openUri($doc_dest);
  11. $xw->startDocument('1.0', 'UTF-8');
  12. $xw->startElement("tag1");
  13. $xw->startPi("PHP");
  14. $xw->text('echo $a;');
  15. $xw->endPi();
  16. $xw->endDocument();
  17. // Force to write and empty the buffer
  18. $xw->flush(true);
  19. $md5_out = md5_file($doc_dest);
  20. $md5_res = md5('<?xml version="1.0" encoding="UTF-8"?>
  21. <tag1><?PHP echo $a;?></tag1>
  22. ');
  23. unset($xw);
  24. unlink('001.xml');
  25. if ($md5_out != $md5_res) {
  26. echo "failed: $md5_res != $md5_out\n";
  27. } else {
  28. echo "ok.\n";
  29. }
  30. ?>
  31. ===DONE===
  32. --EXPECT--
  33. ok.
  34. ===DONE===