xref: /PHP-7.2/ext/phar/tests/bug79082.phpt (revision e5c95234)
1--TEST--
2Phar: Bug #79082: Files added to tar with Phar::buildFromIterator have all-access permissions
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6if (defined("PHP_WINDOWS_VERSION_MAJOR")) die("skip not for Windows")
7?>
8--FILE--
9<?php
10umask(022);
11var_dump(decoct(umask()));
12chmod(__DIR__ . '/test79082/test79082-testfile', 0644);
13chmod(__DIR__ . '/test79082/test79082-testfile2', 0400);
14
15foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $mode => $ext) {
16	clearstatcache();
17	$phar = new PharData(__DIR__ . '/test79082.' . $ext, null, null, $mode);
18	$phar->buildFromIterator(new \RecursiveDirectoryIterator(__DIR__ . '/test79082', \FilesystemIterator::SKIP_DOTS), __DIR__ . '/test79082');
19	$phar->extractTo(__DIR__);
20	var_dump(decoct(stat(__DIR__ . '/test79082-testfile')['mode']));
21	var_dump(decoct(stat(__DIR__ . '/test79082-testfile2')['mode']));
22	unlink(__DIR__ . '/test79082-testfile');
23	unlink(__DIR__ . '/test79082-testfile2');
24}
25foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $mode => $ext) {
26	clearstatcache();
27	$phar = new PharData(__DIR__ . '/test79082-d.' . $ext, null, null, $mode);
28	$phar->buildFromDirectory(__DIR__ . '/test79082');
29	$phar->extractTo(__DIR__);
30	var_dump(decoct(stat(__DIR__ . '/test79082-testfile')['mode']));
31	var_dump(decoct(stat(__DIR__ . '/test79082-testfile2')['mode']));
32	unlink(__DIR__ . '/test79082-testfile');
33	unlink(__DIR__ . '/test79082-testfile2');
34}
35?>
36--CLEAN--
37<?
38unlink(__DIR__ . '/test79082.tar');
39unlink(__DIR__ . '/test79082.zip');
40unlink(__DIR__ . '/test79082-d.tar');
41unlink(__DIR__ . '/test79082-d.zip');
42?>
43--EXPECT--
44string(2) "22"
45string(6) "100644"
46string(6) "100400"
47string(6) "100644"
48string(6) "100400"
49string(6) "100644"
50string(6) "100400"
51string(6) "100644"
52string(6) "100400"
53