1--TEST--
2Test readfile() function : variation - various invalid paths
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--SKIPIF--
6<?php
7if(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
18echo "*** Testing readfile() : variation ***\n";
19
20/* An array of files */
21$names_arr = array(
22  /* Invalid args */
23  "-1" => -1,
24  "TRUE" => TRUE,
25  "FALSE" => FALSE,
26  "NULL" => NULL,
27  "\"\"" => "",
28  "\" \"" => " ",
29  "\\0" => "\0",
30  "array()" => array(),
31
32  /* prefix with path separator of a non existing directory*/
33  "/no/such/file/dir" => "/no/such/file/dir",
34  "php/php"=> "php/php"
35
36);
37
38foreach($names_arr as $key => $value) {
39      echo "\n-- Filename: $key --\n";
40      readfile($value);
41};
42
43?>
44===Done===
45--EXPECTF--
46*** Testing readfile() : variation ***
47
48-- Filename: -1 --
49
50Warning: readfile(-1): failed to open stream: No such file or directory in %s on line %d
51
52-- Filename: TRUE --
53
54Warning: readfile(1): failed to open stream: No such file or directory in %s on line %d
55
56-- Filename: FALSE --
57
58Warning: readfile(): Filename cannot be empty in %s on line %d
59
60-- Filename: NULL --
61
62Warning: readfile(): Filename cannot be empty in %s on line %d
63
64-- Filename: "" --
65
66Warning: readfile(): Filename cannot be empty in %s on line %d
67
68-- Filename: " " --
69
70Warning: readfile( ): failed to open stream: Permission denied in %s on line %d
71
72-- Filename: \0 --
73
74Warning: readfile() expects parameter 1 to be a valid path, string given in %s on line %d
75
76-- Filename: array() --
77
78Warning: readfile() expects parameter 1 to be a valid path, array given in %s on line %d
79
80-- Filename: /no/such/file/dir --
81
82Warning: readfile(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d
83
84-- Filename: php/php --
85
86Warning: readfile(php/php): failed to open stream: No such file or directory in %s on line %d
87===Done===
88