oo_getcomment.phpt 752 B

1234567891011121314151617181920212223242526272829303132333435
  1. --TEST--
  2. getComment
  3. --SKIPIF--
  4. <?php
  5. if(!extension_loaded('zip')) die('skip');
  6. ?>
  7. --FILE--
  8. <?php
  9. $dirname = dirname(__FILE__) . '/';
  10. $file = $dirname . 'test_with_comment.zip';
  11. include $dirname . 'utils.inc';
  12. $zip = new ZipArchive;
  13. if (!$zip->open($file)) {
  14. exit('failed');
  15. }
  16. echo $zip->getArchiveComment() . "\n";
  17. $idx = $zip->locateName('foo');
  18. echo $zip->getCommentName('foo') . "\n";
  19. echo $zip->getCommentIndex($idx);
  20. echo $zip->getCommentName('') . "\n";
  21. echo $zip->getCommentName() . "\n";
  22. $zip->close();
  23. ?>
  24. --EXPECTF--
  25. Zip archive comment
  26. foo comment
  27. foo comment
  28. Notice: ZipArchive::getCommentName(): Empty string as entry name in %s on line %d
  29. Warning: ZipArchive::getCommentName() expects at least 1 parameter, 0 given in %s on line %d