file_basic.phpt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. --TEST--
  2. Test file() function : basic functionality
  3. --FILE--
  4. <?php
  5. /*
  6. * Description: Reads entire file into an array
  7. */
  8. require(__DIR__ . '/file.inc');
  9. $file_path = __DIR__;
  10. echo "*** Testing file() with basic types of files ***\n";
  11. $filetypes = array("numeric", "text", "empty", "text_with_new_line");
  12. foreach( $filetypes as $type ) {
  13. create_files($file_path, 1, $type, 0755, 100, "w", "file_basic", 1, "byte");
  14. print_r( file($file_path."/file_basic1.tmp") );
  15. delete_files($file_path, 1, "file_basic");
  16. }
  17. echo "*** Testing for return type of file() function ***\n";
  18. foreach( $filetypes as $type ) {
  19. create_files($file_path, 1, $type, 0755, 1, "w", "file_basic");
  20. $ret_arr = file($file_path."/file_basic1.tmp");
  21. var_dump( is_array($ret_arr) );
  22. delete_files($file_path, 1, "file_basic");
  23. }
  24. echo "\n--- Done ---";
  25. ?>
  26. --EXPECT--
  27. *** Testing file() with basic types of files ***
  28. Array
  29. (
  30. [0] => 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
  31. )
  32. Array
  33. (
  34. [0] => text text text text text text text text text text text text text text text text text text text text
  35. )
  36. Array
  37. (
  38. )
  39. Array
  40. (
  41. [0] => line
  42. [1] => line of text
  43. [2] => line
  44. [3] => line of text
  45. [4] => line
  46. [5] => line of text
  47. [6] => line
  48. [7] => line of text
  49. [8] => line
  50. [9] => line of text
  51. [10] => line
  52. [11] => line
  53. )
  54. *** Testing for return type of file() function ***
  55. bool(true)
  56. bool(true)
  57. bool(true)
  58. bool(true)
  59. --- Done ---