xref: /PHP-7.1/ext/phar/tests/phar_setalias2.phpt (revision 7af945e2)
1--TEST--
2Phar::setAlias() error
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.require_hash=0
7phar.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
19include 'files/phar_test.inc';
20
21$phar = new Phar($fname);
22echo $phar->getAlias() . "\n";
23$phar->setAlias('test');
24echo $phar->getAlias() . "\n";
25$b = $phar;
26$phar = new Phar(dirname(__FILE__) . '/notphar.phar');
27try {
28	$phar->setAlias('test');
29} catch (Exception $e) {
30	echo $e->getMessage() . "\n";
31}
32try {
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
41unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
42unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.php');
43unlink(dirname(__FILE__) . '/notphar.phar');
44__HALT_COMPILER();
45?>
46--EXPECTF--
47hio
48test
49alias "test" is already used for archive "%sphar_setalias2.phar.php" and cannot be used for other archives
50alias "test" is already used for archive "%sphar_setalias2.phar.php" cannot be overloaded with "%snope.phar"
51===DONE===
52