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