xref: /PHP-5.5/ext/phar/tests/zip/phar_setalias.phpt (revision 16b4d8e0)
1--TEST--
2Phar::setAlias() zip-based
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5<?php if (!extension_loaded("zlib")) die("skip no zlib"); ?>
6<?php if (!extension_loaded("bz2")) die("skip no bz2"); ?>
7--INI--
8phar.require_hash=0
9phar.readonly=0
10--FILE--
11<?php
12
13$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
14$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar.zip';
15$fname3 = dirname(__FILE__) . '/' . 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===DONE===
50--CLEAN--
51<?php
52unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
53unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.zip');
54unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '3.phar.zip');
55__HALT_COMPILER();
56?>
57--EXPECT--
58hio
59test
60test
61test
62===DONE===
63