Annotation of embedaddon/php/ext/zip/tests/oo_extract.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: extractTo
                      3: --SKIPIF--
                      4: <?php
1.1.1.2 ! misho       5: /* $Id$ */
1.1       misho       6: if(!extension_loaded('zip')) die('skip');
                      7: ?>
                      8: --FILE--
                      9: <?php
                     10: $dirname = dirname(__FILE__) . '/';
                     11: $file = $dirname . 'test_with_comment.zip';
                     12: include $dirname . 'utils.inc';
                     13: $zip = new ZipArchive;
                     14: if ($zip->open($file) !== TRUE) {
                     15:        echo "open failed.\n";
                     16:        exit('failed');
                     17: }
                     18: 
                     19: $zip->extractTo($dirname . '__oo_extract_tmp');
                     20: if (!is_dir($dirname . '__oo_extract_tmp')) {
                     21:        echo "failed. mkdir\n";
                     22: }
                     23: 
                     24: if (!is_dir($dirname .'__oo_extract_tmp/foobar')) {
                     25:        echo "failed. mkdir foobar\n";
                     26: }
                     27: 
                     28: if (!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: 
                     34: if (!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: 
                     40: if (!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');
                     49: if (!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'));
                     57: if (!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: }
                     62: if (!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: 
                     68: rmdir_rf($dirname . '__oo_extract_tmp');
                     69: ?>
                     70: --EXPECTF--
                     71: blabla laber rababer sülz
                     72: 
                     73: bar
                     74: 
                     75: foo
                     76: 
                     77: 
                     78: bar
                     79: 
                     80: bar
                     81: 
                     82: foo
                     83: --UEXPECTF--
                     84: blabla laber rababer sülz
                     85: 
                     86: bar
                     87: 
                     88: foo
                     89: 
                     90: 
                     91: bar
                     92: 
                     93: bar
                     94: 
                     95: foo

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>