oo_namelocate.phpt 923 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Locate entries by name
  3. --EXTENSIONS--
  4. zip
  5. --FILE--
  6. <?php
  7. $dirname = __DIR__ . '/';
  8. include $dirname . 'utils.inc';
  9. $file = $dirname . 'oo_namelocate.zip';
  10. @unlink($file);
  11. $zip = new ZipArchive;
  12. if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
  13. exit('failed');
  14. }
  15. $zip->addFromString('entry1.txt', 'entry #1');
  16. $zip->addFromString('entry2.txt', 'entry #2');
  17. $zip->addFromString('dir/entry2d.txt', 'entry #2');
  18. if (!$zip->status == ZIPARCHIVE::ER_OK) {
  19. echo "failed to write zip\n";
  20. }
  21. $zip->close();
  22. if (!$zip->open($file)) {
  23. exit('failed');
  24. }
  25. var_dump($zip->locateName('entry1.txt'));
  26. var_dump($zip->locateName('eNtry2.txt'));
  27. var_dump($zip->locateName('eNtry2.txt', ZIPARCHIVE::FL_NOCASE));
  28. var_dump($zip->locateName('enTRy2d.txt', ZIPARCHIVE::FL_NOCASE|ZIPARCHIVE::FL_NODIR));
  29. $zip->close();
  30. ?>
  31. --EXPECT--
  32. int(0)
  33. bool(false)
  34. int(1)
  35. int(2)
  36. --CLEAN--
  37. <?php
  38. unlink(__DIR__ . '/oo_namelocate.zip');
  39. ?>