1--TEST--
2Phar: context/compress=BZip2
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5<?php if (!extension_loaded("bz2")) die("skip bz2 not present"); ?>
6--INI--
7phar.readonly=0
8phar.require_hash=0
9--FILE--
10<?php
11$fname = dirname(__FILE__) . '/' . 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', b'new b');
34file_put_contents($pname . '/c', b'new c', 0, $context);
35file_put_contents($pname . '/d', b'new d');
36file_put_contents($pname . '/e', b'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===DONE===
52--CLEAN--
53<?php
54unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
55?>
56--EXPECTF--
57string(1) "a"
58bool(false)
59string(1) "b"
60bool(false)
61string(1) "c"
62bool(false)
63string(1) "a"
64bool(false)
65string(5) "new b"
66bool(false)
67string(5) "new c"
68bool(true)
69string(5) "new d"
70bool(false)
71string(5) "new e"
72bool(true)
73===DONE===
74