finfo_buffer_basic-mb.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Test finfo_buffer() function : basic functionality
  3. --EXTENSIONS--
  4. fileinfo
  5. --FILE--
  6. <?php
  7. $magicFile = __DIR__ . DIRECTORY_SEPARATOR . 'magic私はガラスを食べられます';
  8. $options = array(
  9. FILEINFO_NONE,
  10. FILEINFO_MIME,
  11. );
  12. $buffers = array(
  13. "Regular string here",
  14. "\177ELF",
  15. "\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003",
  16. "\x55\x7A\x6E\x61",
  17. "id=ImageMagick\x0a\x0c\x0a:\x1a",
  18. "RIFFüîò^BAVI LISTv",
  19. );
  20. echo "*** Testing finfo_buffer() : basic functionality ***\n";
  21. foreach( $options as $option ) {
  22. $finfo = finfo_open( $option, $magicFile );
  23. foreach( $buffers as $string ) {
  24. var_dump( finfo_buffer( $finfo, $string, $option ) );
  25. }
  26. finfo_close( $finfo );
  27. }
  28. ?>
  29. --EXPECT--
  30. *** Testing finfo_buffer() : basic functionality ***
  31. string(36) "ASCII text, with no line terminators"
  32. string(3) "ELF"
  33. string(22) "old ACE/gr binary file"
  34. string(12) "xo65 object,"
  35. string(15) "MIFF image data"
  36. string(25) "RIFF (little-endian) data"
  37. string(28) "text/plain; charset=us-ascii"
  38. string(26) "text/plain; charset=ebcdic"
  39. string(40) "application/octet-stream; charset=binary"
  40. string(28) "text/plain; charset=us-ascii"
  41. string(28) "image/x-miff; charset=binary"
  42. string(25) "text/plain; charset=utf-8"