xref: /PHP-7.4/ext/phar/tests/bug79912.phpt (revision 4c1b3e30)
1--TEST--
2Bug #79912 (Phar::decompressFiles not working)
3--SKIPIF--
4<?php
5if (!extension_loaded('phar')) die('skip phar extension is not available');
6if (!extension_loaded('zlib')) die('skip zlib extension not available');
7?>
8--INI--
9phar.readonly=0
10--FILE--
11<?php
12$phar = new Phar(__DIR__ . "/bug79912.phar");
13$phar->addFromString("test.txt", "This is a test file.This is a test file.This is a test file.");
14$file = $phar["test.txt"];
15var_dump($file->compress(Phar::GZ)); //true (success)
16var_dump($file->getContent());
17var_dump($file->isCompressed()); //true (the file is compressed)
18var_dump($phar->decompressFiles()); //true (success)
19var_dump($file->isCompressed()); //false (the file should not be compressed anymore)
20var_dump($phar->extractTo(__DIR__ . "/bug79912")); //true
21var_dump(file_get_contents(__DIR__ . "/bug79912/test.txt")); //the extracted file in the folder should be decompressed
22?>
23--EXPECT--
24bool(true)
25string(60) "This is a test file.This is a test file.This is a test file."
26bool(true)
27bool(true)
28bool(false)
29bool(true)
30string(60) "This is a test file.This is a test file.This is a test file."
31--CLEAN--
32<?php
33@unlink(__DIR__ . "/bug79912/test.txt");
34@rmdir(__DIR__ . "/bug79912");
35@unlink(__DIR__ . "/bug79912.phar");
36?>
37