Annotation of embedaddon/php/ext/standard/tests/file/file_get_contents_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test file_get_contents() function : error conditions
3: --CREDITS--
4: Dave Kelsey <d_kelsey@uk.ibm.com>
5: --FILE--
6: <?php
7: /* Prototype: string file_get_contents( string $filename{, bool $use_include_path[,
8: * resource $context[, int $offset[, int $maxlen]]]] )
9: * Description: Reads entire file into a string
10: */
11:
12: echo "*** Testing error conditions ***\n";
13:
14: $file_path = dirname(__FILE__);
15: include($file_path."/file.inc");
16:
17: echo "\n-- Testing with Non-existing file --\n";
18: print( file_get_contents("/no/such/file/or/dir") );
19:
20: echo "\n-- Testing No.of arguments less than expected --\n";
21: print( file_get_contents() );
22:
23: echo "\n-- Testing No.of arguments greater than expected --\n";
24:
25: create_files($file_path, 1, "text", 0755, 100, "w", "file", 1, "byte");
26: $file_handle = fopen($file_path."/file_put_contents_error.tmp", "w");
27: print( file_get_contents($file_path."/file1.tmp", false, $file_handle, 1, 2, "extra_argument") );
28:
29: echo "\n-- Testing for invalid negative maxlen values --";
30: var_dump( file_get_contents($file_path."/file1.tmp", FALSE, $file_handle, 0, -5) );
31:
32: delete_files($file_path, 1);
33: fclose($file_handle);
34: unlink($file_path."/file_put_contents_error.tmp");
35:
36: echo "\n*** Done ***\n";
37: ?>
38: --CLEAN--
39: <?php
40: $file_path = dirname(__FILE__);
41: if(file_exists($file_path."/file_put_contents_error.tmp")) {
42: unlink($file_path."/file_put_contents_error.tmp");
43: }
44: if(file_exists($file_path."/file_put_contents1.tmp")) {
45: unlink($file_path."/file_put_contents1.tmp");
46: }
47: ?>
48: --EXPECTF--
49: *** Testing error conditions ***
50:
51: -- Testing with Non-existing file --
52:
53: Warning: file_get_contents(/no/such/file/or/dir): failed to open stream: No such file or directory in %s on line %d
54:
55: -- Testing No.of arguments less than expected --
56:
57: Warning: file_get_contents() expects at least 1 parameter, 0 given in %s on line %d
58:
59: -- Testing No.of arguments greater than expected --
60:
61: Warning: file_get_contents() expects at most 5 parameters, 6 given in %s on line %d
62:
63: -- Testing for invalid negative maxlen values --
64: Warning: file_get_contents(): length must be greater than or equal to zero in %s on line %d
65: bool(false)
66:
67: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>