xref: /PHP-8.3/ext/phar/tests/033a.phpt (revision 4e121896)
1--TEST--
2Phar::chmod
3--EXTENSIONS--
4phar
5--INI--
6phar.readonly=1
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$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.1.phar.php';
17$pname = 'phar://hio';
18$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
19
20$files = array();
21$files['a.php']   = '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>';
22include 'files/phar_test.inc';
23try {
24    $a = new Phar($fname);
25    var_dump($a['a.php']->isExecutable());
26    $a['a.php']->chmod(0777);
27    var_dump($a['a.php']->isExecutable());
28    $a['a.php']->chmod(0666);
29    var_dump($a['a.php']->isExecutable());
30} catch (Exception $e) {
31    echo $e->getMessage() . "\n";
32}
33?>
34--CLEAN--
35<?php
36unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
37?>
38--EXPECTF--
39bool(false)
40Cannot modify permissions for file "a.php" in phar "%s033a.1.phar.php", write operations are prohibited
41