xref: /PHP-8.3/ext/phar/tests/bug77022.phpt (revision 74859783)
1--TEST--
2Phar: Bug #77022: PharData always creates new files with mode 0666
3--EXTENSIONS--
4phar
5--SKIPIF--
6<?php
7if (defined("PHP_WINDOWS_VERSION_MAJOR")) die("skip not for Windows")
8?>
9--FILE--
10<?php
11umask(022);
12var_dump(decoct(umask()));
13
14$sFile = tempnam(__DIR__, 'test77022');
15var_dump(decoct(stat($sFile)['mode']));
16
17foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $format => $ext) {
18    clearstatcache();
19    $phar = new PharData(__DIR__ . '/test77022.' . $ext, format: $format);
20    $phar->addFile($sFile, 'test-file-phar');
21    $phar->addFromString("test-from-string", 'test-file-phar');
22    $phar->extractTo(__DIR__);
23    var_dump(decoct(stat(__DIR__ . '/test-file-phar')['mode']));
24    var_dump(decoct(stat(__DIR__ . '/test-from-string')['mode']));
25    unlink(__DIR__ . '/test-file-phar');
26    unlink(__DIR__ . '/test-from-string');
27    unlink(__DIR__ . '/test77022.' . $ext);
28}
29unlink($sFile);
30?>
31--EXPECT--
32string(2) "22"
33string(6) "100600"
34string(6) "100600"
35string(6) "100644"
36string(6) "100600"
37string(6) "100644"
38