phar_begin_setstub_commit.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. Phar::startBuffering()/setStub()/stopBuffering()
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded("phar")) die("skip");
  6. ?>
  7. --INI--
  8. phar.require_hash=0
  9. phar.readonly=0
  10. --FILE--
  11. <?php
  12. $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
  13. //var_dump($p->getStub());
  14. var_dump($p->isBuffering());
  15. $p->startBuffering();
  16. var_dump($p->isBuffering());
  17. $p['a.php'] = '<?php var_dump("Hello");';
  18. $p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
  19. include 'phar://brandnewphar.phar/a.php';
  20. var_dump($p->getStub());
  21. $p['b.php'] = '<?php var_dump("World");';
  22. $p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER();');
  23. include 'phar://brandnewphar.phar/b.php';
  24. var_dump($p->getStub());
  25. $p->stopBuffering();
  26. echo "===COMMIT===\n";
  27. var_dump($p->isBuffering());
  28. include 'phar://brandnewphar.phar/a.php';
  29. include 'phar://brandnewphar.phar/b.php';
  30. var_dump($p->getStub());
  31. ?>
  32. ===DONE===
  33. --CLEAN--
  34. <?php
  35. unlink(dirname(__FILE__) . '/brandnewphar.phar');
  36. ?>
  37. --EXPECT--
  38. bool(false)
  39. bool(true)
  40. string(5) "Hello"
  41. string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
  42. "
  43. string(5) "World"
  44. string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
  45. "
  46. ===COMMIT===
  47. bool(false)
  48. string(5) "Hello"
  49. string(5) "World"
  50. string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
  51. "
  52. ===DONE===