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