xref: /PHP-8.4/ext/phar/tests/zip/033.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$fname2 = __DIR__ . '/' . 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--CLEAN--
42<?php
43unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
44unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip');
45?>
46--EXPECT--
47bool(false)
48bool(true)
49bool(false)
50test dir
51bool(true)
52bool(true)
53bool(false)
54bool(true)
55