xref: /PHP-5.6/ext/phar/tests/zip/all.phpt (revision cd23986a)
1--TEST--
2Phar: test that creation of zip-based phar generates valid zip with all bells/whistles
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 (!extension_loaded("bz2")) die("skip bz2 not available");
10?>
11--INI--
12phar.readonly=0
13--FILE--
14<?php
15
16$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
17$pname = 'phar://' . $fname;
18$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip.php';
19$pname2 = 'phar://' . $fname2;
20
21$phar = new Phar($fname);
22
23$phar->setMetadata('hi there');
24$phar['a'] = 'hi';
25$phar['a']->setMetadata('a meta');
26$phar['b'] = 'hi2';
27$phar['b']->compress(Phar::GZ);
28$phar['c'] = 'hi3';
29$phar['c']->compress(Phar::BZ2);
30$phar['b']->chmod(0444);
31$phar->setStub("<?php ok __HALT_COMPILER();");
32$phar->setAlias("hime");
33unset($phar);
34copy($fname, $fname2);
35Phar::unlinkArchive($fname);
36var_dump(file_exists($fname), file_exists($pname . '/a'));
37
38$phar = new Phar($fname2);
39var_dump($phar['a']->getContent(), $phar['b']->getContent(), $phar['c']->getContent());
40var_dump($phar['a']->isCompressed(), $phar['b']->isCompressed() == Phar::GZ, $phar['c']->isCompressed() == Phar::BZ2);
41var_dump((string) decoct(fileperms($pname2 . '/b')));
42var_dump($phar->getStub());
43var_dump($phar->getAlias());
44var_dump($phar->getMetadata());
45var_dump($phar['a']->getMetadata());
46?>
47===DONE===
48--CLEAN--
49<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
50<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip.php'); ?>
51--EXPECT--
52bool(false)
53bool(false)
54string(2) "hi"
55string(3) "hi2"
56string(3) "hi3"
57bool(false)
58bool(true)
59bool(true)
60string(6) "100444"
61string(32) "<?php ok __HALT_COMPILER(); ?>
62"
63string(4) "hime"
64string(8) "hi there"
65string(6) "a meta"
66===DONE===
67