xref: /PHP-8.2/ext/phar/tests/029.phpt (revision 74859783)
1--TEST--
2Phar::loadPhar overloading alias names
3--EXTENSIONS--
4phar
5--INI--
6phar.require_hash=0
7--FILE--
8<?php
9$fname1 = __DIR__ . '/' . basename(__FILE__, '.php') . '.1.phar.php';
10$fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.2.phar.php';
11$fname = $fname1;
12$alias = '';
13$pname = 'phar://hio';
14$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
15
16$files = array();
17$files['a.php']   = '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>';
18$files['b.php']   = '<?php echo "This is b\n"; include "'.$pname.'/b/c.php"; ?>';
19$files['b/c.php'] = '<?php echo "This is b/c\n"; include "'.$pname.'/b/d.php"; ?>';
20$files['b/d.php'] = '<?php echo "This is b/d\n"; include "'.$pname.'/e.php"; ?>';
21$files['e.php']   = '<?php echo "This is e\n"; ?>';
22
23include 'files/phar_test.inc';
24
25copy($fname1, $fname2);
26
27var_dump(Phar::loadPhar($fname1, 'hio'));
28var_dump(Phar::loadPhar($fname1, 'copy'));
29$a = new Phar($fname1);
30try
31{
32    var_dump(Phar::loadPhar($fname2, 'copy'));
33}
34catch (Exception $e)
35{
36    echo $e->getMessage() . "\n";
37}
38
39?>
40--CLEAN--
41<?php
42unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
43unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.phar.php');
44?>
45--EXPECTF--
46bool(true)
47bool(true)
48alias "copy" is already used for archive "%s029.1.phar.php" cannot be overloaded with "%s029.2.phar.php"
49