xref: /PHP-5.6/ext/phar/tests/phar_extract3.phpt (revision 14d53417)
1--TEST--
2Phar: Phar::extractTo() - check that phar exists
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9
10$fname   = dirname(__FILE__) . '/files/bogus.zip';
11$fname2  = dirname(__FILE__) . '/files/notbogus.zip';
12$extract = dirname(__FILE__) . '/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===DONE===
35--CLEAN--
36<?php
37$dir = dirname(__FILE__) . '/test-extract3/';
38@unlink($dir . 'stuff.txt');
39@unlink($dir . 'nonsense.txt');
40@rmdir($dir);
41?>
42--EXPECTF--
43Invalid argument, %sfiles/bogus.zip cannot be found
44phar://%sfiles/notbogus.zip%cnonsense.txt
45phar://%sfiles/notbogus.zip%cstuff.txt
46===DONE===
47