xref: /PHP-8.1/ext/phar/tests/phar_bz2.phpt (revision 74859783)
1--TEST--
2Phar: bzipped phar
3--EXTENSIONS--
4phar
5bz2
6--INI--
7phar.readonly=0
8phar.require_hash=0
9--FILE--
10<?php
11$fname = __DIR__ . '/phar_bz2.phar';
12$pname = 'phar://' . $fname;
13$fname2 = __DIR__ . '/phar_bz2.2.phar';
14$pname2 = 'phar://' . $fname2;
15
16$file = '<?php
17Phar::mapPhar();
18var_dump("it worked");
19include "phar://" . __FILE__ . "/tar_004.php";
20__HALT_COMPILER();';
21
22$files = array();
23$files['tar_004.php']   = '<?php var_dump(__FILE__);';
24$files['internal/file/here']   = "hi there!\n";
25$files['internal/dir/'] = '';
26$files['dir/'] = '';
27$bz2 = true;
28
29include 'files/phar_test.inc';
30
31include $fname;
32
33$a = new Phar($fname);
34$a['test'] = 'hi';
35copy($fname, $fname2);
36$a->setAlias('another');
37$b = new Phar($fname2);
38var_dump($b->isFileFormat(Phar::PHAR));
39var_dump($b->isCompressed() == Phar::BZ2);
40// additional code coverage
41try {
42$b->isFileFormat(25);
43} catch (Exception $e) {
44echo $e->getMessage(),"\n";
45}
46?>
47--CLEAN--
48<?php
49@unlink(__DIR__ . '/phar_bz2.phar');
50@unlink(__DIR__ . '/phar_bz2.2.phar');
51?>
52--EXPECTF--
53string(9) "it worked"
54string(%d) "phar://%sphar_bz2.phar/tar_004.php"
55bool(true)
56bool(true)
57Unknown file format specified
58