File: readfile_error.phpt

package info (click to toggle)
php5 5.6.33%2Bdfsg-0%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 157,872 kB
  • sloc: ansic: 756,065; php: 22,030; sh: 12,311; cpp: 8,771; xml: 6,179; yacc: 1,564; exp: 1,514; makefile: 1,467; pascal: 1,147; awk: 538; perl: 315; sql: 22
file content (61 lines) | stat: -rw-r--r-- 1,973 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
--TEST--
Test readfile() function: error conditions
--FILE--
<?php
/* Prototype: int readfile ( string $filename [, bool $use_include_path [, resource $context]] );
   Description: Outputs a file
*/

$context = stream_context_create();

echo "*** Test readfile(): error conditions ***\n";
echo "-- Testing readfile() with unexpected no. of arguments --\n";
var_dump( readfile() );  // args < expected
var_dump( readfile(__FILE__, true, $context, 4) );  // args > expected

echo "\n-- Testing readfile() with invalid arguments --\n";
// invalid arguments
var_dump( readfile(NULL) );  // NULL as $filename
var_dump( readfile('') );  // empty string as $filename
var_dump( readfile(false) );  // boolean false as $filename
var_dump( readfile(__FILE__, false, '') );  // empty string as $context
var_dump( readfile(__FILE__, true, false) );  // boolean false as $context

echo "\n-- Testing readfile() with non-existent file --\n";
$non_existent_file = dirname(__FILE__)."/non_existent_file.tmp";
var_dump( readfile($non_existent_file) );

echo "Done\n";
?>
--EXPECTF--
*** Test readfile(): error conditions ***
-- Testing readfile() with unexpected no. of arguments --

Warning: readfile() expects at least 1 parameter, 0 given in %s on line %d
bool(false)

Warning: readfile() expects at most 3 parameters, 4 given in %s on line %d
bool(false)

-- Testing readfile() with invalid arguments --

Warning: readfile(): Filename cannot be empty in %s on line %d
bool(false)

Warning: readfile(): Filename cannot be empty in %s on line %d
bool(false)

Warning: readfile(): Filename cannot be empty in %s on line %d
bool(false)

Warning: readfile() expects parameter 3 to be resource, string given in %s on line %d
bool(false)

Warning: readfile() expects parameter 3 to be resource, boolean given in %s on line %d
bool(false)

-- Testing readfile() with non-existent file --

Warning: readfile(%s/non_existent_file.tmp): failed to open stream: %s in %s on line %d
bool(false)
Done