xref: /PHP-5.6/ext/zip/tests/oo_extract.phpt (revision 8ad0c6d5)
1--TEST--
2extractTo
3--SKIPIF--
4<?php
5/* $Id$ */
6if(!extension_loaded('zip')) die('skip');
7?>
8--FILE--
9<?php
10$dirname = dirname(__FILE__) . '/';
11$file = $dirname . 'test_with_comment.zip';
12include $dirname . 'utils.inc';
13$zip = new ZipArchive;
14if ($zip->open($file) !== TRUE) {
15	echo "open failed.\n";
16	exit('failed');
17}
18
19$zip->extractTo($dirname . '__oo_extract_tmp');
20if (!is_dir($dirname . '__oo_extract_tmp')) {
21	echo "failed. mkdir\n";
22}
23
24if (!is_dir($dirname .'__oo_extract_tmp/foobar')) {
25	echo "failed. mkdir foobar\n";
26}
27
28if (!file_exists($dirname . '__oo_extract_tmp/foobar/baz')) {
29	echo "failed. extract foobar/baz\n";
30} else {
31	echo file_get_contents($dirname . '__oo_extract_tmp/foobar/baz') . "\n";
32}
33
34if (!file_exists($dirname . '__oo_extract_tmp/bar')) {
35	echo "failed. bar file\n";
36} else {
37	echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n";
38}
39
40if (!file_exists($dirname . '__oo_extract_tmp/foo')) {
41	echo "failed. foo file\n";
42} else {
43	echo file_get_contents($dirname . '__oo_extract_tmp/foo') . "\n";
44}
45
46
47/* extract one file */
48$zip->extractTo($dirname . '__oo_extract_tmp', 'bar');
49if (!file_exists($dirname . '__oo_extract_tmp/bar')) {
50	echo "failed. extract  bar file\n";
51} else {
52	echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n";
53}
54
55/* extract two files */
56$zip->extractTo($dirname . '__oo_extract_tmp', array('bar','foo'));
57if (!file_exists($dirname . '__oo_extract_tmp/bar')) {
58	echo "failed. extract  bar file\n";
59} else {
60	echo file_get_contents($dirname . '__oo_extract_tmp/bar') . "\n";
61}
62if (!file_exists($dirname . '__oo_extract_tmp/foo')) {
63	echo "failed. extract foo file\n";
64} else {
65	echo file_get_contents($dirname . '__oo_extract_tmp/foo') . "\n";
66}
67
68rmdir_rf($dirname . '__oo_extract_tmp');
69?>
70--EXPECTF--
71blabla laber rababer sülz
72
73bar
74
75foo
76
77
78bar
79
80bar
81
82foo
83--UEXPECTF--
84blabla laber rababer sülz
85
86bar
87
88foo
89
90
91bar
92
93bar
94
95foo
96