finfo_file_regex.phpt 786 B

1234567891011121314151617181920212223242526272829
  1. --TEST--
  2. Test finfo_file() function : regex rules
  3. --SKIPIF--
  4. <?php require_once(dirname(__FILE__) . '/skipif.inc');
  5. ?>
  6. --FILE--
  7. <?php
  8. /**
  9. * Works with the unix file command:
  10. * $ file -m magic resources/test.awk
  11. * resources/test.awk: awk script, ASCII text
  12. */
  13. $magicFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'magic';
  14. $finfo = finfo_open( FILEINFO_MIME, $magicFile );
  15. echo "*** Testing finfo_file() : regex rules ***\n";
  16. // Calling finfo_file() with all possible arguments
  17. $file = __DIR__ . '/resources/test.awk';
  18. var_dump( finfo_file( $finfo, $file ) );
  19. var_dump( finfo_file( $finfo, $file, FILEINFO_CONTINUE ) );
  20. ?>
  21. ===DONE===
  22. --EXPECTF--
  23. *** Testing finfo_file() : regex rules ***
  24. string(28) "text/plain; charset=us-ascii"
  25. string(22) "awk script, ASCII text"
  26. ===DONE===