diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/standard/tests/file/readfile_error.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/standard/tests/file/readfile_error.phpt')
-rw-r--r-- | ext/standard/tests/file/readfile_error.phpt | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/ext/standard/tests/file/readfile_error.phpt b/ext/standard/tests/file/readfile_error.phpt new file mode 100644 index 0000000..2d5d377 --- /dev/null +++ b/ext/standard/tests/file/readfile_error.phpt @@ -0,0 +1,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 |