Annotation of embedaddon/php/ext/standard/tests/file/readfile_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test readfile() function: error conditions
3: --FILE--
4: <?php
5: /* Prototype: int readfile ( string $filename [, bool $use_include_path [, resource $context]] );
6: Description: Outputs a file
7: */
8:
9: $context = stream_context_create();
10:
11: echo "*** Test readfile(): error conditions ***\n";
12: echo "-- Testing readfile() with unexpected no. of arguments --\n";
13: var_dump( readfile() ); // args < expected
14: var_dump( readfile(__FILE__, true, $context, 4) ); // args > expected
15:
16: echo "\n-- Testing readfile() with invalid arguments --\n";
17: // invalid arguments
18: var_dump( readfile(NULL) ); // NULL as $filename
19: var_dump( readfile('') ); // empty string as $filename
20: var_dump( readfile(false) ); // boolean false as $filename
21: var_dump( readfile(__FILE__, false, '') ); // empty string as $context
22: var_dump( readfile(__FILE__, true, false) ); // boolean false as $context
23:
24: echo "\n-- Testing readfile() with non-existent file --\n";
25: $non_existent_file = dirname(__FILE__)."/non_existent_file.tmp";
26: var_dump( readfile($non_existent_file) );
27:
28: echo "Done\n";
29: ?>
30: --EXPECTF--
31: *** Test readfile(): error conditions ***
32: -- Testing readfile() with unexpected no. of arguments --
33:
34: Warning: readfile() expects at least 1 parameter, 0 given in %s on line %d
35: bool(false)
36:
37: Warning: readfile() expects at most 3 parameters, 4 given in %s on line %d
38: bool(false)
39:
40: -- Testing readfile() with invalid arguments --
41:
42: Warning: readfile(): Filename cannot be empty in %s on line %d
43: bool(false)
44:
45: Warning: readfile(): Filename cannot be empty in %s on line %d
46: bool(false)
47:
48: Warning: readfile(): Filename cannot be empty in %s on line %d
49: bool(false)
50:
51: Warning: readfile() expects parameter 3 to be resource, string given in %s on line %d
52: bool(false)
53:
54: Warning: readfile() expects parameter 3 to be resource, boolean given in %s on line %d
55: bool(false)
56:
57: -- Testing readfile() with non-existent file --
58:
59: Warning: readfile(%s/non_existent_file.tmp): failed to open stream: %s in %s on line %d
60: bool(false)
61: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>