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      var_dump(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
51bool(false)
52
53-- Filename: TRUE --
54
55Warning: readfile(1): failed to open stream: No such file or directory in %s on line %d
56bool(false)
57
58-- Filename: FALSE --
59
60Warning: readfile(): Filename cannot be empty in %s on line %d
61bool(false)
62
63-- Filename: NULL --
64
65Warning: readfile(): Filename cannot be empty in %s on line %d
66bool(false)
67
68-- Filename: "" --
69
70Warning: readfile(): Filename cannot be empty in %s on line %d
71bool(false)
72
73-- Filename: " " --
74
75Warning: readfile( ): failed to open stream: Permission denied in %s on line %d
76bool(false)
77
78-- Filename: \0 --
79bool(false)
80
81-- Filename: array() --
82
83Warning: readfile() expects parameter 1 to be string, array given in %s on line %d
84bool(false)
85
86-- Filename: /no/such/file/dir --
87
88Warning: readfile(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d
89bool(false)
90
91-- Filename: php/php --
92
93Warning: readfile(php/php): failed to open stream: No such file or directory in %s on line %d
94bool(false)
95===Done===