phar_setalias2.phpt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --TEST--
  2. Phar::setAlias() error
  3. --EXTENSIONS--
  4. phar
  5. --INI--
  6. phar.require_hash=0
  7. phar.readonly=0
  8. --FILE--
  9. <?php
  10. $fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
  11. $pname = 'phar://' . $fname;
  12. $file = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
  13. $files = array();
  14. $files['a'] = 'a';
  15. $files['b'] = 'b';
  16. $files['c'] = 'c';
  17. include 'files/phar_test.inc';
  18. $phar = new Phar($fname);
  19. echo $phar->getAlias() . "\n";
  20. $phar->setAlias('test');
  21. echo $phar->getAlias() . "\n";
  22. $b = $phar;
  23. $phar = new Phar(__DIR__ . '/notphar.phar');
  24. try {
  25. $phar->setAlias('test');
  26. } catch (Exception $e) {
  27. echo $e->getMessage() . "\n";
  28. }
  29. try {
  30. $b = new Phar(__DIR__ . '/nope.phar', 0, 'test');
  31. } catch (Exception $e) {
  32. echo $e->getMessage() . "\n";
  33. }
  34. ?>
  35. --CLEAN--
  36. <?php
  37. unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
  38. unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phartmp.php');
  39. unlink(__DIR__ . '/notphar.phar');
  40. __HALT_COMPILER();
  41. ?>
  42. --EXPECTF--
  43. hio
  44. test
  45. alias "test" is already used for archive "%sphar_setalias2.phar.php" and cannot be used for other archives
  46. alias "test" is already used for archive "%sphar_setalias2.phar.php" cannot be overloaded with "%snope.phar"