bug64342_0.phpt 756 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. Bug #64342 ZipArchive::addFile() has to check file existence (variation 1)
  3. --EXTENSIONS--
  4. zip
  5. --FILE--
  6. <?php
  7. $zip = new ZipArchive;
  8. $res = $zip->open(__DIR__ . '/bug64342.zip', ZipArchive::CREATE);
  9. if ($res === TRUE) {
  10. $f = md5(uniqid()) . '.txt';
  11. echo "$f\n";
  12. $res = $zip->addFile($f);
  13. if (true == $res) {
  14. echo "add ok\n";
  15. } else {
  16. echo "add failed\n";
  17. }
  18. $res = $zip->close();
  19. if (true == $res) {
  20. echo "close ok\n";
  21. } else {
  22. echo "close failed\n";
  23. }
  24. } else {
  25. echo "open failed\n";
  26. }
  27. ?>
  28. DONE
  29. --CLEAN--
  30. <?php
  31. @unlink(__DIR__ . '/bug64342.zip');
  32. ?>
  33. --EXPECTF--
  34. %s.txt
  35. Warning: ZipArchive::addFile(): No such file or directory in %s on line %d
  36. add failed
  37. close ok
  38. DONE