1--TEST--
2Phar: context/compress=BZip2
3--EXTENSIONS--
4phar
5bz2
6--INI--
7phar.readonly=0
8phar.require_hash=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$context = stream_context_create(array('phar'=>array('compress'=>Phar::BZ2)));
32
33file_put_contents($pname . '/b', 'new b');
34file_put_contents($pname . '/c', 'new c', 0, $context);
35file_put_contents($pname . '/d', 'new d');
36file_put_contents($pname . '/e', 'new e', 0, $context);
37
38$phar = new Phar($fname);
39var_dump(file_get_contents($pname . '/a'));
40var_dump($phar['a']->isCompressed());
41var_dump(file_get_contents($pname . '/b'));
42var_dump($phar['b']->isCompressed());
43var_dump(file_get_contents($pname . '/c'));
44var_dump($phar['c']->isCompressed());
45var_dump(file_get_contents($pname . '/d'));
46var_dump($phar['d']->isCompressed());
47var_dump(file_get_contents($pname . '/e'));
48var_dump($phar['e']->isCompressed());
49
50?>
51--CLEAN--
52<?php
53unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
54?>
55--EXPECT--
56string(1) "a"
57bool(false)
58string(1) "b"
59bool(false)
60string(1) "c"
61bool(false)
62string(1) "a"
63bool(false)
64string(5) "new b"
65bool(false)
66string(5) "new c"
67bool(true)
68string(5) "new d"
69bool(false)
70string(5) "new e"
71bool(true)
72