phar_commitwrite.phpt 913 B

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