1
0
mirror of https://github.com/php/php-src.git synced 2026-04-24 00:18:23 +02:00
Files
archived-php-src/ext/hash/tests/hash_file_error.phpt
T
Fabien Villepinte a555cc0b3d Clean DONE tags from tests
Remove most of the `===DONE===` tags and its variations.
Keep `===DONE===` if the test output otherwise becomes empty.

Closes GH-4872.
2019-11-07 21:31:47 +01:00

47 lines
1.2 KiB
PHP

--TEST--
Hash: hash_file() function : error conditions
--CREDITS--
Felix De Vliegher <felix.devliegher@gmail.com>
--FILE--
<?php
/* Prototype : string hash_file(string algo, string filename[, bool raw_output = false])
* Description: Generate a hash of a given file
* Source code: ext/hash/hash.c
* Alias to functions:
*/
echo "*** Testing hash_file() : error conditions ***\n";
// Set up file
$filename = 'hash_file_error_example.txt';
file_put_contents( $filename, 'The quick brown fox jumped over the lazy dog.' );
// hash_file() error tests
echo "\n-- Testing hash_file() function with an unknown algorithm --\n";
var_dump( hash_file( 'foobar', $filename ) );
echo "\n-- Testing hash_file() function with a non-existent file --\n";
var_dump( hash_file( 'md5', 'nonexistent.txt' ) );
?>
--CLEAN--
<?php
$filename = 'hash_file_error_example.txt';
unlink( $filename );
?>
--EXPECTF--
*** Testing hash_file() : error conditions ***
-- Testing hash_file() function with an unknown algorithm --
Warning: hash_file(): Unknown hashing algorithm: %s in %s on line %d
bool(false)
-- Testing hash_file() function with a non-existent file --
Warning: hash_file(%s): failed to open stream: No such file or directory in %s on line %d
bool(false)