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