xref: /PHP-7.4/ext/phar/tests/phar_bz2.phpt (revision 26dfce7f)
1--TEST--
2Phar: bzipped phar
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
13$fname = __DIR__ . '/phar_bz2.phar';
14$pname = 'phar://' . $fname;
15$fname2 = __DIR__ . '/phar_bz2.2.phar';
16$pname2 = 'phar://' . $fname2;
17
18$file = '<?php
19Phar::mapPhar();
20var_dump("it worked");
21include "phar://" . __FILE__ . "/tar_004.php";
22__HALT_COMPILER();';
23
24$files = array();
25$files['tar_004.php']   = '<?php var_dump(__FILE__);';
26$files['internal/file/here']   = "hi there!\n";
27$files['internal/dir/'] = '';
28$files['dir/'] = '';
29$bz2 = true;
30
31include 'files/phar_test.inc';
32
33include $fname;
34
35$a = new Phar($fname);
36$a['test'] = 'hi';
37copy($fname, $fname2);
38$a->setAlias('another');
39$b = new Phar($fname2);
40var_dump($b->isFileFormat(Phar::PHAR));
41var_dump($b->isCompressed() == Phar::BZ2);
42// additional code coverage
43$b->isFileFormat(array());
44try {
45$b->isFileFormat(25);
46} catch (Exception $e) {
47echo $e->getMessage(),"\n";
48}
49?>
50===DONE===
51--CLEAN--
52<?php
53@unlink(__DIR__ . '/phar_bz2.phar');
54@unlink(__DIR__ . '/phar_bz2.2.phar');
55?>
56--EXPECTF--
57string(9) "it worked"
58string(%d) "phar://%sphar_bz2.phar/tar_004.php"
59bool(true)
60bool(true)
61
62Warning: Phar::isFileFormat() expects parameter 1 to be int, array given in %sphar_bz2.php on line %d
63Unknown file format specified
64===DONE===
65