finfo_buffer_basic.phpt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. --TEST--
  2. Test finfo_buffer() function : basic functionality
  3. --SKIPIF--
  4. <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
  5. --FILE--
  6. <?php
  7. /* Prototype : string finfo_buffer(resource finfo, char *string [, int options [, resource context]])
  8. * Description: Return infromation about a string buffer.
  9. * Source code: ext/fileinfo/fileinfo.c
  10. * Alias to functions:
  11. */
  12. $magicFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'magic';
  13. $options = array(
  14. FILEINFO_NONE,
  15. FILEINFO_MIME,
  16. );
  17. $buffers = array(
  18. "Regular string here",
  19. "\177ELF",
  20. "\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003",
  21. "\x55\x7A\x6E\x61",
  22. "id=ImageMagick",
  23. "RIFFüîò^BAVI LISTv",
  24. );
  25. echo "*** Testing finfo_buffer() : basic functionality ***\n";
  26. foreach( $options as $option ) {
  27. $finfo = finfo_open( $option, $magicFile );
  28. foreach( $buffers as $string ) {
  29. var_dump( finfo_buffer( $finfo, $string, $option ) );
  30. }
  31. finfo_close( $finfo );
  32. }
  33. ?>
  34. ===DONE===
  35. --EXPECTF--
  36. *** Testing finfo_buffer() : basic functionality ***
  37. string(36) "ASCII text, with no line terminators"
  38. string(3) "ELF"
  39. string(22) "old ACE/gr binary file"
  40. string(12) "xo65 object,"
  41. string(15) "MIFF image data"
  42. string(25) "RIFF (little-endian) data"
  43. string(28) "text/plain; charset=us-ascii"
  44. string(26) "text/plain; charset=ebcdic"
  45. string(40) "application/octet-stream; charset=binary"
  46. string(28) "text/plain; charset=us-ascii"
  47. string(28) "text/plain; charset=us-ascii"
  48. string(25) "text/plain; charset=utf-8"
  49. ===DONE===