xref: /PHP-7.2/ext/phar/tests/zip/033.phpt (revision 16b4d8e0)
1--TEST--
2Phar::chmod zip-based
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.readonly=0
7phar.require_hash=0
8--FILE--
9<?php
10
11$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
12$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip';
13$alias = 'phar://hio';
14
15$phar = new Phar($fname);
16$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
17$phar->setAlias('hio');
18$phar->addEmptyDir('test');
19$phar->stopBuffering();
20
21try {
22	var_dump($phar['a.php']->isExecutable());
23	$phar['a.php']->chmod(0777);
24	copy($fname, $fname2);
25	$phar->setAlias('unused');
26	$phar2 = new Phar($fname2);
27	var_dump($phar2['a.php']->isExecutable());
28	$phar['a.php']->chmod(0666);
29	var_dump($phar['a.php']->isExecutable());
30	echo "test dir\n";
31	var_dump($phar['test']->isDir());
32	var_dump($phar['test']->isReadable());
33	$phar['test']->chmod(0000);
34	var_dump($phar['test']->isReadable());
35	$phar['test']->chmod(0666);
36	var_dump($phar['test']->isReadable());
37} catch (Exception $e) {
38	echo $e->getMessage() . "\n";
39}
40?>
41===DONE===
42--CLEAN--
43<?php
44unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
45unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip');
46?>
47--EXPECT--
48bool(false)
49bool(true)
50bool(false)
51test dir
52bool(true)
53bool(true)
54bool(false)
55bool(true)
56===DONE===
57