Annotation of embedaddon/php/ext/hash/tests/hash_file_error.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test hash_file() function : error conditions 
                      3: --SKIPIF--
                      4: <?php extension_loaded('hash') or die('skip: hash extension not loaded.'); ?>
                      5: --CREDITS--
                      6: Felix De Vliegher <felix.devliegher@gmail.com>
                      7: --FILE--
                      8: <?php
                      9: /* Prototype  : string hash_file(string algo, string filename[, bool raw_output = false])
                     10:  * Description: Generate a hash of a given file
                     11:  * Source code: ext/hash/hash.c
                     12:  * Alias to functions: 
                     13:  */
                     14: 
                     15: echo "*** Testing hash_file() : error conditions ***\n";
                     16: 
                     17: // Set up file
                     18: $filename = 'hash_file_example.txt';
                     19: file_put_contents( $filename, 'The quick brown fox jumped over the lazy dog.' );
                     20: 
                     21: 
                     22: // hash_file() error tests
                     23: echo "\n-- Testing hash_file() function with an unknown algorithm --\n";
                     24: var_dump( hash_file( 'foobar', $filename ) );
                     25: 
                     26: echo "\n-- Testing hash_file() function with a non-existant file --\n";
                     27: var_dump( hash_file( 'md5', 'nonexistant.txt' ) );
                     28: 
                     29: echo "\n-- Testing hash_file() function with less than expected no. of arguments --\n";
                     30: var_dump( hash_file( 'md5' ) );
                     31: 
                     32: echo "\n-- Testing hash_file() function with more than expected no. of arguments --\n";
                     33: $extra_arg = 10;
                     34: var_dump( hash_file( 'md5', $filename, false, $extra_arg ) );
                     35: 
                     36: ?>
                     37: ===DONE===
                     38: --CLEAN--
                     39: <?php
                     40: 
                     41: $filename = 'hash_file_example.txt';
                     42: unlink( $filename );
                     43: 
                     44: ?>
                     45: --EXPECTF--
                     46: *** Testing hash_file() : error conditions ***
                     47: 
                     48: -- Testing hash_file() function with an unknown algorithm --
                     49: 
                     50: Warning: hash_file(): Unknown hashing algorithm: %s in %s on line %d
                     51: bool(false)
                     52: 
                     53: -- Testing hash_file() function with a non-existant file --
                     54: 
                     55: Warning: hash_file(%s): failed to open stream: No such file or directory in %s on line %d
                     56: bool(false)
                     57: 
                     58: -- Testing hash_file() function with less than expected no. of arguments --
                     59: 
                     60: Warning: hash_file() expects at least 2 parameters, 1 given in %s on line %d
                     61: NULL
                     62: 
                     63: -- Testing hash_file() function with more than expected no. of arguments --
                     64: 
                     65: Warning: hash_file() expects at most 3 parameters, 4 given in %s on line %d
                     66: NULL
                     67: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>