oo_getcomment.phpt 660 B

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