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