xref: /PHP-8.4/ext/phar/tests/phar_extract3.phpt (revision 74859783)
1--TEST--
2Phar: Phar::extractTo() - check that phar exists
3--EXTENSIONS--
4phar
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9
10$fname   = __DIR__ . '/files/bogus.zip';
11$fname2  = __DIR__ . '/files/notbogus.zip';
12$extract = __DIR__ . '/test-extract3';
13
14$phar = new PharData($fname);
15
16try {
17    $phar->extractTo($extract);
18} catch (Exception $e) {
19    echo $e->getMessage(), "\n";
20}
21
22$phar = new PharData($fname2);
23foreach ($phar as $filename) {
24    echo "$filename\n";
25}
26
27try {
28    $phar->extractTo($extract);
29} catch (Exception $e) {
30    echo $e->getMessage(), "\n";
31}
32
33?>
34--CLEAN--
35<?php
36$dir = __DIR__ . '/test-extract3/';
37@unlink($dir . 'stuff.txt');
38@unlink($dir . 'nonsense.txt');
39@rmdir($dir);
40?>
41--EXPECTF--
42Invalid argument, %sfiles/bogus.zip cannot be found
43phar://%sfiles/notbogus.zip%cnonsense.txt
44phar://%sfiles/notbogus.zip%cstuff.txt
45