bug70322.phpt 776 B

123456789101112131415161718192021222324252627
  1. --TEST--
  2. Bug #70322 (ZipArchive::close() doesn't indicate errors)
  3. --DESCRIPTION--
  4. We want to test whether ZipArchive::close() returns FALSE and raises a warning
  5. on failure, so we force the failure by adding a file to the archive, which we
  6. delete before closing.
  7. --EXTENSIONS--
  8. zip
  9. --FILE--
  10. <?php
  11. $zipfile = __DIR__ . '/bug70322.zip';
  12. $textfile = __DIR__ . '/bug70322.txt';
  13. touch($textfile);
  14. $zip = new ZipArchive();
  15. $zip->open($zipfile, ZipArchive::CREATE);
  16. $zip->addFile($textfile);
  17. unlink($textfile);
  18. var_dump($zip->close());
  19. ?>
  20. --CLEAN--
  21. <?php
  22. // we don't expect the archive to be created, but clean up just in case...
  23. @unlink(__DIR__ . '/bug70322.zip');
  24. ?>
  25. --EXPECTF--
  26. Warning: ZipArchive::close(): %s: No such file or directory in %s%ebug70322.php on line %d
  27. bool(false)