1--TEST--
2Test readfile() function: error conditions
3--FILE--
4<?php
5$context = stream_context_create();
6
7echo "*** Test readfile(): error conditions ***\n";
8
9echo "\n-- Testing readfile() with invalid arguments --\n";
10// invalid arguments
11try {
12    var_dump( readfile(NULL) );  // NULL as $filename
13} catch (\ValueError $e) {
14    echo $e->getMessage() . \PHP_EOL;
15}
16try {
17    var_dump( readfile('') );  // empty string as $filename
18} catch (\ValueError $e) {
19    echo $e->getMessage() . \PHP_EOL;
20}
21try {
22    var_dump( readfile(false) );  // boolean false as $filename
23} catch (\ValueError $e) {
24    echo $e->getMessage() . \PHP_EOL;
25}
26
27echo "\n-- Testing readfile() with non-existent file --\n";
28$non_existent_file = __DIR__."/non_existent_file.tmp";
29var_dump( readfile($non_existent_file) );
30
31echo "Done\n";
32?>
33--EXPECTF--
34*** Test readfile(): error conditions ***
35
36-- Testing readfile() with invalid arguments --
37Path cannot be empty
38Path cannot be empty
39Path cannot be empty
40
41-- Testing readfile() with non-existent file --
42
43Warning: readfile(%s/non_existent_file.tmp): Failed to open stream: %s in %s on line %d
44bool(false)
45Done
46