finfo_file_002.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. finfo_file(): Testing mime types
  3. --EXTENSIONS--
  4. fileinfo
  5. --FILE--
  6. <?php
  7. $fp = finfo_open(FILEINFO_MIME_TYPE);
  8. $results = array();
  9. foreach (glob(__DIR__ . "/resources/*") as $filename) {
  10. if (is_file($filename)) {
  11. $results["$filename"] = finfo_file($fp, $filename);
  12. }
  13. }
  14. ksort($results);
  15. var_dump($results);
  16. ?>
  17. --EXPECTF--
  18. array(%d) {
  19. ["%s/resources/dir.zip"]=>
  20. string(15) "application/zip"
  21. ["%s/resources/test.awk"]=>
  22. string(10) "text/plain"
  23. ["%s/resources/test.bmp"]=>
  24. string(14) "image/x-ms-bmp"
  25. ["%s/resources/test.gif"]=>
  26. string(9) "image/gif"
  27. ["%s/resources/test.jpg"]=>
  28. string(10) "image/jpeg"
  29. ["%s/test.json"]=>
  30. string(16) "application/json"
  31. ["%s/resources/test.mp3"]=>
  32. string(10) "audio/mpeg"
  33. ["%s/resources/test.pdf"]=>
  34. string(15) "application/pdf"
  35. ["%s/resources/test.png"]=>
  36. string(9) "image/png"
  37. ["%s/resources/test.ppt"]=>
  38. string(29) "application/vnd.ms-powerpoint"
  39. ["%s/resources/test.tga"]=>
  40. string(11) "image/x-tga"
  41. ["%s/resources/test.webm"]=>
  42. string(10) "video/webm"
  43. ["%s/resources/test.woff"]=>
  44. string(9) "font/woff"
  45. }