readfile_variation10.phpt 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. --TEST--
  2. Test readfile() function : variation - various invalid paths
  3. --CREDITS--
  4. Dave Kelsey <d_kelsey@uk.ibm.com>
  5. --SKIPIF--
  6. <?php
  7. if(substr(PHP_OS, 0, 3) == "WIN")
  8. die("skip Not for Windows");
  9. ?>
  10. --FILE--
  11. <?php
  12. /* Prototype : int readfile(string filename [, bool use_include_path[, resource context]])
  13. * Description: Output a file or a URL
  14. * Source code: ext/standard/file.c
  15. * Alias to functions:
  16. */
  17. echo "*** Testing readfile() : variation ***\n";
  18. /* An array of files */
  19. $names_arr = array(
  20. /* Invalid args */
  21. -1,
  22. TRUE,
  23. FALSE,
  24. NULL,
  25. "",
  26. " ",
  27. "\0",
  28. array(),
  29. /* prefix with path separator of a non existing directory*/
  30. "/no/such/file/dir",
  31. "php/php"
  32. );
  33. for( $i=0; $i<count($names_arr); $i++ ) {
  34. $name = $names_arr[$i];
  35. echo "-- testing '$name' --\n";
  36. readfile($name);
  37. }
  38. echo "\n*** Done ***\n";
  39. ?>
  40. --EXPECTF--
  41. *** Testing readfile() : variation ***
  42. -- testing '-1' --
  43. Warning: readfile(-1): failed to open stream: %s in %s on line %d
  44. -- testing '1' --
  45. Warning: readfile(1): failed to open stream: %s in %s on line %d
  46. -- testing '' --
  47. Warning: readfile(): Filename cannot be empty in %s on line %d
  48. -- testing '' --
  49. Warning: readfile(): Filename cannot be empty in %s on line %d
  50. -- testing '' --
  51. Warning: readfile(): Filename cannot be empty in %s on line %d
  52. -- testing ' ' --
  53. Warning: readfile( ): failed to open stream: %s in %s on line %d
  54. -- testing '�' --
  55. Warning: readfile() expects parameter 1 to be a valid path, string given in %s on line %d
  56. Notice: Array to string conversion in %s line %d
  57. -- testing 'Array' --
  58. Warning: readfile() expects parameter 1 to be a valid path, array given in %s on line %d
  59. -- testing '%sdir' --
  60. Warning: readfile(%sdir): failed to open stream: %s in %s on line %d
  61. -- testing '%sphp' --
  62. Warning: readfile(%sphp): failed to open stream: %s in %s on line %d
  63. *** Done ***