xref: /PHP-5.3/ext/zip/tests/oo_setcomment.phpt (revision 8ad0c6d5)
1--TEST--
2setComment
3--SKIPIF--
4<?php
5/* $Id$ */
6if(!extension_loaded('zip')) die('skip');
7?>
8--FILE--
9<?php
10$dirname = dirname(__FILE__) . '/';
11include $dirname . 'utils.inc';
12$file = $dirname . '__tmp_oo_set_comment.zip';
13
14@unlink($file);
15
16$zip = new ZipArchive;
17if (!$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
28var_dump($zip->setCommentName('entry1.txt', 'entry1.txt'));
29var_dump($zip->setCommentName('entry2.txt', 'entry2.txt'));
30var_dump($zip->setCommentName('dir/entry2d.txt', 'dir/entry2d.txt'));
31var_dump($zip->setArchiveComment('archive'));
32
33var_dump($zip->setCommentIndex(3, 'entry4.txt'));
34var_dump($zip->setCommentIndex(4, 'entry5.txt'));
35var_dump($zip->setArchiveComment('archive'));
36
37if (!$zip->status == ZIPARCHIVE::ER_OK) {
38	echo "failed to write zip\n";
39}
40$zip->close();
41
42if (!$zip->open($file)) {
43	@unlink($file);
44	exit('failed');
45}
46
47var_dump($zip->getCommentIndex(0));
48var_dump($zip->getCommentIndex(1));
49var_dump($zip->getCommentIndex(2));
50var_dump($zip->getCommentIndex(3));
51var_dump($zip->getCommentIndex(4));
52var_dump($zip->getArchiveComment());
53
54$zip->close();
55@unlink($file);
56
57?>
58--EXPECTF--
59bool(true)
60bool(true)
61bool(true)
62bool(true)
63bool(true)
64bool(true)
65bool(true)
66string(10) "entry1.txt"
67string(10) "entry2.txt"
68string(15) "dir/entry2d.txt"
69string(10) "entry4.txt"
70string(10) "entry5.txt"
71string(7) "archive"
72