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
14echo "*** Testing readfile() : variation ***\n";
15
16
17/* An array of files */
18$names_arr = array(
19  /* Invalid args */
20  -1,
21  TRUE,
22  FALSE,
23  NULL,
24  "",
25  " ",
26  "\0",
27
28  /* prefix with path separator of a non existing directory*/
29  "/no/such/file/dir",
30  "php/php"
31
32);
33
34for( $i=0; $i<count($names_arr); $i++ ) {
35    $name = $names_arr[$i];
36    echo "-- testing '$name' --\n";
37    try {
38        readfile($name);
39    } catch (\TypeError|\ValueError $e) {
40        echo get_class($e) . ': ' . $e->getMessage(), "\n";
41    }
42}
43?>
44--EXPECTF--
45*** Testing readfile() : variation ***
46-- testing '-1' --
47
48Warning: readfile(-1): Failed to open stream: %s in %s on line %d
49-- testing '1' --
50
51Warning: readfile(1): Failed to open stream: %s in %s on line %d
52-- testing '' --
53ValueError: Path cannot be empty
54-- testing '' --
55ValueError: Path cannot be empty
56-- testing '' --
57ValueError: Path cannot be empty
58-- testing ' ' --
59
60Warning: readfile( ): Failed to open stream: %s in %s on line %d
61-- testing '�' --
62ValueError: readfile(): Argument #1 ($filename) must not contain any null bytes
63-- testing '%sdir' --
64
65Warning: readfile(%sdir): Failed to open stream: %s in %s on line %d
66-- testing '%sphp' --
67
68Warning: readfile(%sphp): Failed to open stream: %s in %s on line %d
69