1--TEST--
2Phar: alias edge cases
3--EXTENSIONS--
4phar
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9
10$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar';
11$fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.2.phar';
12
13$p = new Phar($fname);
14
15$p->setAlias('foo');
16$p['unused'] = 'hi';
17try {
18$a = new Phar($fname2, 0, 'foo');
19} catch (Exception $e) {
20echo $e->getMessage(),"\n";
21}
22copy($fname, $fname2);
23echo "2\n";
24try {
25$a = new Phar($fname2);
26} catch (Exception $e) {
27echo $e->getMessage(),"\n";
28}
29try {
30$b = new Phar($fname, 0, 'another');
31} catch (Exception $e) {
32echo $e->getMessage(),"\n";
33}
34?>
35--CLEAN--
36<?php
37unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar');
38unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.phar');
39?>
40--EXPECTF--
41alias "foo" is already used for archive "%salias_acrobatics.phar" cannot be overloaded with "%salias_acrobatics.2.phar"
422
43Cannot open archive "%salias_acrobatics.2.phar", alias is already in use by existing archive
44alias "another" is already used for archive "%salias_acrobatics.phar" cannot be overloaded with "%salias_acrobatics.phar"
45