xref: /PHP-8.3/ext/phar/tests/zip/phar_setalias.phpt (revision cd3fbb1b)
1--TEST--
2Phar::setAlias() zip-based
3--EXTENSIONS--
4phar
5zlib
6bz2
7--INI--
8phar.require_hash=0
9phar.readonly=0
10--FILE--
11<?php
12
13$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.zip';
14$fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.2.phar.zip';
15$fname3 = __DIR__ . '/' . basename(__FILE__, '.php') . '.3.phar.zip';
16
17$phar = new Phar($fname);
18$phar->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
19$phar->setAlias('hio');
20
21$files = array();
22
23$files['a'] = 'a';
24$files['b'] = 'b';
25$files['c'] = 'c';
26
27foreach ($files as $n => $file) {
28    $phar[$n] = $file;
29}
30$phar->stopBuffering();
31
32echo $phar->getAlias() . "\n";
33$phar->setAlias('test');
34echo $phar->getAlias() . "\n";
35
36// test compression
37
38$phar->compressFiles(Phar::GZ);
39copy($fname, $fname2);
40$phar->setAlias('unused');
41$p2 = new Phar($fname2);
42echo $p2->getAlias(), "\n";
43$p2->compressFiles(Phar::BZ2);
44copy($fname2, $fname3);
45$p2->setAlias('unused2');
46$p3 = new Phar($fname3);
47echo $p3->getAlias(), "\n";
48?>
49--CLEAN--
50<?php
51unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
52unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip');
53unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.3.phar.zip');
54?>
55--EXPECT--
56hio
57test
58test
59test
60