Annotation of embedaddon/php/ext/phar/tests/phar_setalias2.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Phar::setAlias() error
! 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.php';
! 11: $pname = 'phar://' . $fname;
! 12: $file = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
! 13:
! 14: $files = array();
! 15: $files['a'] = 'a';
! 16: $files['b'] = 'b';
! 17: $files['c'] = 'c';
! 18:
! 19: include 'files/phar_test.inc';
! 20:
! 21: $phar = new Phar($fname);
! 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: try {
! 33: $b = new Phar(dirname(__FILE__) . '/nope.phar', 0, 'test');
! 34: } catch (Exception $e) {
! 35: echo $e->getMessage() . "\n";
! 36: }
! 37: ?>
! 38: ===DONE===
! 39: --CLEAN--
! 40: <?php
! 41: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
! 42: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.php');
! 43: unlink(dirname(__FILE__) . '/notphar.phar');
! 44: __HALT_COMPILER();
! 45: ?>
! 46: --EXPECTF--
! 47: hio
! 48: test
! 49: alias "test" is already used for archive "%sphar_setalias2.phar.php" and cannot be used for other archives
! 50: alias "test" is already used for archive "%sphar_setalias2.phar.php" cannot be overloaded with "%snope.phar"
! 51: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>