phar_commitwrite.phpt 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Phar::setStub()/stopBuffering() zip-based
  3. --SKIPIF--
  4. <?php if (!extension_loaded("phar")) die("skip"); ?>
  5. --INI--
  6. phar.require_hash=0
  7. phar.readonly=0
  8. --ENV--
  9. TEMP=.
  10. TMP=.
  11. --FILE--
  12. <?php
  13. $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar.zip', 0, 'brandnewphar.phar');
  14. $p['file1.txt'] = 'hi';
  15. $p->stopBuffering();
  16. var_dump($p->getStub());
  17. $p->setStub("<?php
  18. function __autoload(\$class)
  19. {
  20. include 'phar://' . str_replace('_', '/', \$class);
  21. }
  22. Phar::mapPhar('brandnewphar.phar');
  23. include 'phar://brandnewphar.phar/startup.php';
  24. __HALT_COMPILER();
  25. ?>");
  26. var_dump($p->getStub());
  27. var_dump($p->isFileFormat(Phar::ZIP));
  28. ?>
  29. ===DONE===
  30. --CLEAN--
  31. <?php
  32. unlink(dirname(__FILE__) . '/brandnewphar.phar.zip');
  33. ?>
  34. --EXPECT--
  35. string(60) "<?php // zip-based phar archive stub file
  36. __HALT_COMPILER();"
  37. string(200) "<?php
  38. function __autoload($class)
  39. {
  40. include 'phar://' . str_replace('_', '/', $class);
  41. }
  42. Phar::mapPhar('brandnewphar.phar');
  43. include 'phar://brandnewphar.phar/startup.php';
  44. __HALT_COMPILER(); ?>
  45. "
  46. bool(true)
  47. ===DONE===