xref: /PHP-7.2/ext/phar/tests/tar/tar_bz2.phpt (revision 113213f0)
1--TEST--
2Phar: tar-based phar, bzipped tar
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6if (!extension_loaded("spl")) die("skip SPL not available");
7if (!extension_loaded("bz2")) die("skip bz2 not available");
8?>
9--INI--
10phar.readonly=0
11phar.require_hash=0
12--FILE--
13<?php
14include dirname(__FILE__) . '/files/tarmaker.php.inc';
15
16$fname = dirname(__FILE__) . '/tar_bz2.phar';
17$alias = 'phar://' . $fname;
18$fname2 = dirname(__FILE__) . '/tar_bz2.phar.tar';
19$alias2 = 'phar://' . $fname2;
20
21$tar = new tarmaker($fname, 'bz2');
22$tar->init();
23$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);');
24$tar->addFile('internal/file/here', "hi there!\n");
25$tar->mkDir('internal/dir');
26$tar->mkDir('dir');
27$tar->addFile('.phar/stub.php', '<?php
28var_dump(__FILE__);
29var_dump(substr(__FILE__, 0, 4) != "phar");
30Phar::mapPhar();
31var_dump("it worked");
32include "phar://" . __FILE__ . "/tar_004.php";
33__HALT_COMPILER();
34');
35$tar->close();
36
37include $alias;
38
39$phar = new Phar($fname);
40$phar['test'] = 'hi';
41
42copy($fname, $fname2);
43
44$phar2 = new Phar($fname2);
45var_dump($phar2->isFileFormat(Phar::TAR));
46var_dump($phar2->isCompressed() == Phar::BZ2);
47
48?>
49===DONE===
50--CLEAN--
51<?php
52@unlink(dirname(__FILE__) . '/tar_bz2.phar');
53@unlink(dirname(__FILE__) . '/tar_bz2.phar.tar');
54?>
55--EXPECTF--
56string(%d) "%star_bz2.phar"
57bool(true)
58string(9) "it worked"
59string(%d) "phar://%star_bz2.phar/tar_004.php"
60bool(true)
61bool(true)
62===DONE===
63