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