readfile_variation10-win32.phpt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 run only on 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" => -1,
  22. "TRUE" => TRUE,
  23. "FALSE" => FALSE,
  24. "NULL" => NULL,
  25. "\"\"" => "",
  26. "\" \"" => " ",
  27. "\\0" => "\0",
  28. "array()" => array(),
  29. /* prefix with path separator of a non existing directory*/
  30. "/no/such/file/dir" => "/no/such/file/dir",
  31. "php/php"=> "php/php"
  32. );
  33. foreach($names_arr as $key => $value) {
  34. echo "\n-- Filename: $key --\n";
  35. readfile($value);
  36. };
  37. ?>
  38. ===Done===
  39. --EXPECTF--
  40. *** Testing readfile() : variation ***
  41. -- Filename: -1 --
  42. Warning: readfile(-1): failed to open stream: No such file or directory in %s on line %d
  43. -- Filename: TRUE --
  44. Warning: readfile(1): failed to open stream: No such file or directory in %s on line %d
  45. -- Filename: FALSE --
  46. Warning: readfile(): Filename cannot be empty in %s on line %d
  47. -- Filename: NULL --
  48. Warning: readfile(): Filename cannot be empty in %s on line %d
  49. -- Filename: "" --
  50. Warning: readfile(): Filename cannot be empty in %s on line %d
  51. -- Filename: " " --
  52. Warning: readfile( ): failed to open stream: Permission denied in %s on line %d
  53. -- Filename: \0 --
  54. Warning: readfile() expects parameter 1 to be a valid path, string given in %s on line %d
  55. -- Filename: array() --
  56. Warning: readfile() expects parameter 1 to be a valid path, array given in %s on line %d
  57. -- Filename: /no/such/file/dir --
  58. Warning: readfile(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d
  59. -- Filename: php/php --
  60. Warning: readfile(php/php): failed to open stream: No such file or directory in %s on line %d
  61. ===Done===