1--TEST--
2Phar::decompressFiles()
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5<?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
6--INI--
7phar.require_hash=0
8phar.readonly=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$phar = new Phar($fname);
32$phar->compressFiles(Phar::GZ);
33var_dump(file_get_contents($pname . '/a'));
34var_dump($phar['a']->isCompressed(Phar::GZ));
35var_dump($phar['a']->isCompressed(Phar::BZ2));
36var_dump(file_get_contents($pname . '/b'));
37var_dump($phar['b']->isCompressed(Phar::GZ));
38var_dump($phar['b']->isCompressed(Phar::BZ2));
39var_dump(file_get_contents($pname . '/c'));
40var_dump($phar['c']->isCompressed(Phar::GZ));
41var_dump($phar['b']->isCompressed(Phar::BZ2));
42
43$phar->decompressFiles();
44var_dump(file_get_contents($pname . '/a'));
45var_dump($phar['a']->isCompressed());
46var_dump(file_get_contents($pname . '/b'));
47var_dump($phar['a']->isCompressed());
48var_dump(file_get_contents($pname . '/c'));
49var_dump($phar['a']->isCompressed());
50
51?>
52===DONE===
53--CLEAN--
54<?php
55unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
56unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
57?>
58--EXPECTF--
59string(1) "a"
60bool(false)
61string(1) "b"
62bool(false)
63string(1) "c"
64bool(false)
65string(1) "a"
66bool(true)
67bool(false)
68string(1) "b"
69bool(true)
70bool(false)
71string(1) "c"
72bool(true)
73bool(false)
74string(1) "a"
75bool(false)
76string(1) "b"
77bool(false)
78string(1) "c"
79bool(false)
80===DONE===
81