xref: /PHP-7.1/ext/phar/tests/phar_gzip.phpt (revision 113213f0)
1--TEST--
2Phar: gzipped phar
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6if (version_compare(PHP_VERSION, "6.0", "==")) die("skip pre-unicode version of PHP required");
7if (!extension_loaded("spl")) die("skip SPL not available");
8if (!extension_loaded("zlib")) die("skip zlib not available");
9if (version_compare(phpversion(), '5.2.6', '<')) die("skip zlib is buggy in PHP < 5.2.6");
10?>
11--INI--
12phar.readonly=0
13phar.require_hash=0
14--FILE--
15<?php
16$fname = dirname(__FILE__) . '/phar_gzip.phar';
17$pname = 'phar://' . $fname;
18$fname2 = dirname(__FILE__) . '/phar_gzip.2.phar';
19$pname2 = 'phar://' . $fname2;
20
21$file = '<?php
22Phar::mapPhar();
23var_dump("it worked");
24include "phar://" . __FILE__ . "/tar_004.php";
25__HALT_COMPILER();';
26
27$files = array();
28$files['tar_004.php']   = '<?php var_dump(__FILE__);';
29$files['internal/file/here']   = "hi there!\n";
30$files['internal/dir/'] = '';
31$files['dir/'] = '';
32$gzip = true;
33
34include 'files/phar_test.inc';
35
36include $fname;
37
38$a = new Phar($fname);
39$a['test'] = 'hi';
40copy($fname, $fname2);
41$a->setAlias('another');
42$b = new Phar($fname2);
43var_dump($b->isFileFormat(Phar::PHAR));
44var_dump($b->isCompressed() == Phar::GZ);
45$a = stat($pname . '/test');
46$b = stat($pname2 . '/test');
47if ($a['mtime'] != $b['mtime']) {
48	echo "timestamp changed, was $a[mtime], now $b[mtime]!\n";
49}
50?>
51===DONE===
52--CLEAN--
53<?php
54@unlink(dirname(__FILE__) . '/phar_gzip.phar');
55@unlink(dirname(__FILE__) . '/phar_gzip.2.phar');
56?>
57--EXPECTF--
58string(9) "it worked"
59string(%d) "phar://%sphar_gzip.phar/tar_004.php"
60bool(true)
61bool(true)
62===DONE===
63