xref: /PHP-8.0/ext/phar/tests/bug52013.phpt (revision 26dfce7f)
1--TEST--
2Test for bug 52013 about Phar::decompressFiles().
3--DESCRIPTION--
4Test for a bug where Phar::decompressFiles() mistakenly throws BadMethodCallException.
5http://bugs.php.net/bug.php?id=52013
6--CREDITS--
7Frederic Hardy frederic.hardy@mageekbox.net
8--SKIPIF--
9<?php
10if (!extension_loaded("phar")) die("skip");
11if (!extension_loaded("zlib")) die("skip test needs zlib extension enabled to compress archives with gzip");
12?>
13--INI--
14phar.require_hash=0
15phar.readonly=0
16open_basedir=
17--FILE--
18<?php
19mkdir(__DIR__ . '/testdir');
20file_put_contents(__DIR__ . '/testdir/1.php', str_repeat(' ', 1455));
21
22$phar = new Phar(__DIR__ . '/compressed.phar');
23$phar->buildFromDirectory(__DIR__ . '/testdir', '/\.php$/');
24$phar->setSignatureAlgorithm(Phar::SHA1);
25$phar->compressFiles(Phar::GZ);
26$phar->decompressFiles();
27
28echo 'ok';
29?>
30--CLEAN--
31<?php
32if (is_file(__DIR__ . '/testdir/1.php'))
33  unlink(__DIR__ . '/testdir/1.php');
34if (is_dir(__DIR__ . '/testdir'))
35  rmdir(__DIR__ . '/testdir');
36if (is_file(__DIR__ . '/compressed.phar'))
37  unlink(__DIR__ . '/compressed.phar');
38?>
39--EXPECT--
40ok
41