phar_begin_setstub_commit.phpt 1.5 KB

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