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 Not for Windows");
9?>
10--CONFLICTS--
11obscure_filename
12--FILE--
13<?php
14/* Prototype  : int readfile(string filename [, bool use_include_path[, resource context]])
15 * Description: Output a file or a URL
16 * Source code: ext/standard/file.c
17 * Alias to functions:
18 */
19
20echo "*** Testing readfile() : variation ***\n";
21
22
23/* An array of files */
24$names_arr = array(
25  /* Invalid args */
26  -1,
27  TRUE,
28  FALSE,
29  NULL,
30  "",
31  " ",
32  "\0",
33  array(),
34
35  /* prefix with path separator of a non existing directory*/
36  "/no/such/file/dir",
37  "php/php"
38
39);
40
41for( $i=0; $i<count($names_arr); $i++ ) {
42  $name = $names_arr[$i];
43  echo "-- testing '$name' --\n";
44  readfile($name);
45}
46?>
47--EXPECTF--
48*** Testing readfile() : variation ***
49-- testing '-1' --
50
51Warning: readfile(-1): failed to open stream: %s in %s on line %d
52-- testing '1' --
53
54Warning: readfile(1): failed to open stream: %s in %s on line %d
55-- testing '' --
56
57Warning: readfile(): Filename cannot be empty in %s on line %d
58-- testing '' --
59
60Warning: readfile(): Filename cannot be empty in %s on line %d
61-- testing '' --
62
63Warning: readfile(): Filename cannot be empty in %s on line %d
64-- testing ' ' --
65
66Warning: readfile( ): failed to open stream: %s in %s on line %d
67-- testing '�' --
68
69Warning: readfile() expects parameter 1 to be a valid path, string given in %s on line %d
70
71Notice: Array to string conversion in %s line %d
72-- testing 'Array' --
73
74Warning: readfile() expects parameter 1 to be a valid path, array given in %s on line %d
75-- testing '%sdir' --
76
77Warning: readfile(%sdir): failed to open stream: %s in %s on line %d
78-- testing '%sphp' --
79
80Warning: readfile(%sphp): failed to open stream: %s in %s on line %d
81