xref: /PHP-5.6/ext/phar/tests/tar/phar_setalias2.phpt (revision 16b4d8e0)
1--TEST--
2Phar::setAlias() error tar-based
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.require_hash=0
7phar.readonly=0
8--FILE--
9<?php
10
11$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
12
13$phar = new Phar($fname);
14$phar->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
15$phar->setAlias('hio');
16
17$files = array();
18
19$files['a'] = 'a';
20$files['b'] = 'b';
21$files['c'] = 'c';
22
23foreach ($files as $n => $file) {
24	$phar[$n] = $file;
25}
26
27$phar->stopBuffering();
28
29echo $phar->getAlias() . "\n";
30$phar->setAlias('test');
31echo $phar->getAlias() . "\n";
32$b = $phar;
33$phar = new Phar(dirname(__FILE__) . '/notphar.phar');
34
35try {
36	$phar->setAlias('test');
37} catch (Exception $e) {
38	echo $e->getMessage() . "\n";
39}
40
41?>
42===DONE===
43--CLEAN--
44<?php
45unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
46unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.tar');
47__HALT_COMPILER();
48?>
49--EXPECTF--
50hio
51test
52alias "test" is already used for archive "%sphar_setalias2.phar.tar" and cannot be used for other archives
53===DONE===
54