Annotation of embedaddon/php/ext/zip/tests/oo_setcomment.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: setComment
3: --SKIPIF--
4: <?php
5: /* $Id: oo_setcomment.phpt 260091 2008-05-21 09:27:41Z pajoye $ */
6: if(!extension_loaded('zip')) die('skip');
7: ?>
8: --FILE--
9: <?php
10: $dirname = dirname(__FILE__) . '/';
11: include $dirname . 'utils.inc';
12: $file = $dirname . '__tmp_oo_set_comment.zip';
13:
14: @unlink($file);
15:
16: $zip = new ZipArchive;
17: if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
18: exit('failed');
19: }
20:
21: $zip->addFromString('entry1.txt', 'entry #1');
22: $zip->addFromString('entry2.txt', 'entry #2');
23: $zip->addFromString('dir/entry2d.txt', 'entry #2');
24: $zip->addFromString('entry4.txt', 'entry #1');
25: $zip->addFromString('entry5.txt', 'entry #2');
26:
27:
28: var_dump($zip->setCommentName('entry1.txt', 'entry1.txt'));
29: var_dump($zip->setCommentName('entry2.txt', 'entry2.txt'));
30: var_dump($zip->setCommentName('dir/entry2d.txt', 'dir/entry2d.txt'));
31: var_dump($zip->setArchiveComment('archive'));
32:
33: var_dump($zip->setCommentIndex(3, 'entry4.txt'));
34: var_dump($zip->setCommentIndex(4, 'entry5.txt'));
35: var_dump($zip->setArchiveComment('archive'));
36:
37: if (!$zip->status == ZIPARCHIVE::ER_OK) {
38: echo "failed to write zip\n";
39: }
40: $zip->close();
41:
42: if (!$zip->open($file)) {
43: @unlink($file);
44: exit('failed');
45: }
46:
47: var_dump($zip->getCommentIndex(0));
48: var_dump($zip->getCommentIndex(1));
49: var_dump($zip->getCommentIndex(2));
50: var_dump($zip->getCommentIndex(3));
51: var_dump($zip->getCommentIndex(4));
52: var_dump($zip->getArchiveComment());
53:
54: $zip->close();
55: @unlink($file);
56:
57: ?>
58: --EXPECTF--
59: bool(true)
60: bool(true)
61: bool(true)
62: bool(true)
63: bool(true)
64: bool(true)
65: bool(true)
66: string(10) "entry1.txt"
67: string(10) "entry2.txt"
68: string(15) "dir/entry2d.txt"
69: string(10) "entry4.txt"
70: string(10) "entry5.txt"
71: string(7) "archive"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>