xref: /PHP-8.2/ext/zip/tests/oo_getcomment.phpt (revision 74859783)
1--TEST--
2getComment
3--EXTENSIONS--
4zip
5--FILE--
6<?php
7$dirname = __DIR__ . '/';
8$file = $dirname . 'test_with_comment.zip';
9include $dirname . 'utils.inc';
10$zip = new ZipArchive;
11if (!$zip->open($file)) {
12    exit('failed');
13}
14echo $zip->getArchiveComment() . "\n";
15
16$idx = $zip->locateName('foo');
17var_dump($zip->getCommentName('foo'));
18var_dump($zip->getCommentIndex($idx));
19
20try {
21    echo $zip->getCommentName('') . "\n";
22} catch (\ValueError $e) {
23    echo $e->getMessage() . \PHP_EOL;
24}
25
26$zip->close();
27
28?>
29--EXPECT--
30Zip archive comment
31string(11) "foo comment"
32string(11) "foo comment"
33ZipArchive::getCommentName(): Argument #1 ($name) cannot be empty
34