xref: /PHP-8.1/ext/phar/tests/zip/033a.phpt (revision 74859783)
1--TEST--
2Phar::chmod zip-based
3--EXTENSIONS--
4phar
5--INI--
6phar.readonly=0
7phar.require_hash=0
8--FILE--
9<?php
10
11$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.zip';
12$alias = 'phar://hio';
13
14$phar = new Phar($fname);
15$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
16$phar->setAlias('hio');
17$phar->addEmptyDir('test');
18$phar->stopBuffering();
19ini_set('phar.readonly', 1);
20
21try {
22    var_dump($phar['a.php']->isExecutable());
23    $phar['a.php']->chmod(0777);
24    var_dump($phar['a.php']->isExecutable());
25    $phar['a.php']->chmod(0666);
26    var_dump($phar['a.php']->isExecutable());
27    echo "test dir\n";
28    var_dump($phar['test']->isExecutable());
29    $phar['test']->chmod(0777);
30    var_dump($phar['test']->isExecutable());
31    $phar['test']->chmod(0666);
32    var_dump($phar['test']->isExecutable());
33} catch (Exception $e) {
34    echo $e->getMessage() . "\n";
35}
36?>
37--CLEAN--
38<?php
39unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
40?>
41--EXPECTF--
42bool(false)
43Cannot modify permissions for file "a.php" in phar "%sa.phar.zip", write operations are prohibited
44