phar_setalias2.phpt 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --TEST--
  2. Phar::setAlias() error zip-based
  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. $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
  11. $phar = new Phar($fname);
  12. $phar->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
  13. $phar->setAlias('hio');
  14. $files = array();
  15. $files['a'] = 'a';
  16. $files['b'] = 'b';
  17. $files['c'] = 'c';
  18. foreach ($files as $n => $file) {
  19. $phar[$n] = $file;
  20. }
  21. $phar->stopBuffering();
  22. echo $phar->getAlias() . "\n";
  23. $phar->setAlias('test');
  24. echo $phar->getAlias() . "\n";
  25. $b = $phar;
  26. $phar = new Phar(dirname(__FILE__) . '/notphar.phar');
  27. try {
  28. $phar->setAlias('test');
  29. } catch (Exception $e) {
  30. echo $e->getMessage() . "\n";
  31. }
  32. ?>
  33. ===DONE===
  34. --CLEAN--
  35. <?php
  36. unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
  37. __HALT_COMPILER();
  38. ?>
  39. --EXPECTF--
  40. hio
  41. test
  42. alias "test" is already used for archive "%sphar_setalias2.phar.zip" and cannot be used for other archives
  43. ===DONE===