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