Annotation of embedaddon/php/ext/zip/tests/oo_delete.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Delete entries
! 3: --SKIPIF--
! 4: <?php
! 5: /* $Id: oo_delete.phpt 265694 2008-08-30 23:55:04Z pajoye $ */
! 6: if(!extension_loaded('zip')) die('skip');
! 7: ?>
! 8: --FILE--
! 9: <?php
! 10: $dirname = dirname(__FILE__) . '/';
! 11: $file = $dirname . '__tmp_oo_delete.zip';
! 12: if (file_exists($file)) {
! 13: unlink($file);
! 14: }
! 15:
! 16: $zip = new ZipArchive;
! 17: if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
! 18: exit('failed');
! 19: }
! 20: $zip->addFromString('entry1.txt', 'entry #1');
! 21: $zip->addFromString('entry2.txt', 'entry #2');
! 22: $zip->addFromString('dir/entry2.txt', 'entry #2');
! 23:
! 24: if ($zip->status == ZIPARCHIVE::ER_OK) {
! 25: $zip->close();
! 26: echo "ok\n";
! 27: } else {
! 28: var_dump($zip);
! 29: echo "failed\n";
! 30: }
! 31:
! 32: if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
! 33: exit('failed');
! 34: }
! 35:
! 36: if ($zip->deleteIndex(0)) {
! 37: echo "ok\n";
! 38: }
! 39:
! 40: if ($zip->deleteName('entry2.txt')) {
! 41: echo "ok\n";
! 42: } else {
! 43: echo "failed 3\n";
! 44: }
! 45:
! 46: if ($zip->deleteName('dir/entry2.txt')) {
! 47: echo "ok\n";
! 48: } else {
! 49: echo "failed 3\n";
! 50: }
! 51:
! 52: if (!$zip->deleteIndex(123)) {
! 53: echo "ok\n";
! 54: } else {
! 55: print_r($zip);
! 56: echo "failed\n";
! 57: }
! 58:
! 59:
! 60: $sb = $zip->statIndex(0);
! 61: var_dump($sb);
! 62: $sb = $zip->statIndex(1);
! 63: var_dump($sb);
! 64: $sb = $zip->statIndex(2);
! 65: var_dump($sb);
! 66: $zip->close();
! 67: unset($zip);
! 68:
! 69: if (file_exists($file)) {
! 70: unlink($file);
! 71: }
! 72: ?>
! 73: --EXPECTF--
! 74: ok
! 75: ok
! 76: ok
! 77: ok
! 78: ok
! 79: bool(false)
! 80: bool(false)
! 81: bool(false)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>