phar_commitwrite.phpt 986 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Phar::setStub()/stopBuffering() zip-based
  3. --EXTENSIONS--
  4. phar
  5. --INI--
  6. phar.require_hash=0
  7. phar.readonly=0
  8. --FILE--
  9. <?php
  10. $p = new Phar(__DIR__ . '/phar_commitwrite.phar.zip', 0, 'phar_commitwrite.phar');
  11. $p['file1.txt'] = 'hi';
  12. $p->stopBuffering();
  13. var_dump($p->getStub());
  14. $p->setStub("<?php
  15. spl_autoload_register(function(\$class) {
  16. include 'phar://' . str_replace('_', '/', \$class);
  17. });
  18. Phar::mapPhar('phar_commitwrite.phar');
  19. include 'phar://phar_commitwrite.phar/startup.php';
  20. __HALT_COMPILER();
  21. ?>");
  22. var_dump($p->getStub());
  23. var_dump($p->isFileFormat(Phar::ZIP));
  24. ?>
  25. --CLEAN--
  26. <?php
  27. unlink(__DIR__ . '/phar_commitwrite.phar.zip');
  28. ?>
  29. --EXPECTF--
  30. string(60) "<?php // zip-based phar archive stub file
  31. __HALT_COMPILER();"
  32. string(%d) "<?php
  33. spl_autoload_register(function($class) {
  34. include 'phar://' . str_replace('_', '/', $class);
  35. });
  36. Phar::mapPhar('phar_commitwrite.phar');
  37. include 'phar://phar_commitwrite.phar/startup.php';
  38. __HALT_COMPILER(); ?>
  39. "
  40. bool(true)