1--TEST--
2Phar: PharFileInfo::compress(Phar::BZ2)
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5<?php if (!extension_loaded("bz2")) die("skip bz2 not present"); ?>
6--INI--
7phar.require_hash=0
8phar.readonly=0
9--FILE--
10<?php
11$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
12$pname = 'phar://' . $fname;
13$file = '<?php __HALT_COMPILER(); ?>';
14
15$files = array();
16$files['a'] = 'a';
17$files['b'] = 'b';
18$files['c'] = 'c';
19
20include 'files/phar_test.inc';
21
22$phar = new Phar($fname);
23
24var_dump(file_get_contents($pname . '/a'));
25var_dump($phar['a']->isCompressed());
26var_dump(file_get_contents($pname . '/b'));
27var_dump($phar['b']->isCompressed());
28var_dump(file_get_contents($pname . '/c'));
29var_dump($phar['c']->isCompressed());
30
31$phar['a'] = 'new a';
32$phar['a']->decompress();
33$phar['b'] = 'new b';
34$phar['b']->compress(Phar::BZ2);
35$phar['d'] = 'new d';
36
37$phar = new Phar($fname);
38var_dump(file_get_contents($pname . '/a'));
39var_dump($phar['a']->isCompressed());
40var_dump(file_get_contents($pname . '/b'));
41var_dump($phar['b']->isCompressed());
42var_dump(file_get_contents($pname . '/c'));
43var_dump($phar['c']->isCompressed());
44var_dump(file_get_contents($pname . '/d'));
45var_dump($phar['d']->isCompressed());
46
47?>
48===DONE===
49--CLEAN--
50<?php
51unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
52?>
53--EXPECT--
54string(1) "a"
55bool(false)
56string(1) "b"
57bool(false)
58string(1) "c"
59bool(false)
60string(5) "new a"
61bool(false)
62string(5) "new b"
63bool(true)
64string(1) "c"
65bool(false)
66string(5) "new d"
67bool(false)
68===DONE===
69