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

1.1       misho       1: --TEST--
                      2: Test hash_hmac_file() function : basic functionality 
                      3: --SKIPIF--
                      4: <?php extension_loaded('hash') or die('skip: hash extension not loaded.'); ?>
                      5: --FILE--
                      6: <?php
                      7: 
                      8: /* Prototype  : string hash_hmac_file ( string algo, string filename, string key [, bool raw_output] )
                      9:  * Description: Generate a keyed hash value using the HMAC method and the contents of a given file
                     10:  * Source code: ext/hash/hash.c
                     11:  * Alias to functions: 
                     12: */
                     13: 
                     14: echo "*** Testing hash() : error conditions ***\n";
                     15: 
                     16: $file = dirname(__FILE__) . "hash_file.txt";
                     17: $key = 'secret';
                     18: 
                     19: echo "\n-- Testing hash_hmac_file() function with less than expected no. of arguments --\n";
                     20: var_dump(hash_hmac_file());
                     21: var_dump(hash_hmac_file('crc32'));
                     22: var_dump(hash_hmac_file('crc32', $file));
                     23: 
                     24: echo "\n-- Testing hash_hmac_file() function with more than expected no. of arguments --\n";
                     25: $extra_arg = 10; 
                     26: hash_hmac_file('crc32', $file, $key, TRUE, $extra_arg);
                     27: 
                     28: echo "\n-- Testing hash_hmac_file() function with invalid hash algorithm --\n";
                     29: hash_hmac_file('foo', $file, $key, TRUE);
                     30: 
                     31: ?>
                     32: ===Done===
                     33: --EXPECTF--
                     34: *** Testing hash() : error conditions ***
                     35: 
                     36: -- Testing hash_hmac_file() function with less than expected no. of arguments --
                     37: 
                     38: Warning: hash_hmac_file() expects at least 3 parameters, 0 given in %s on line %d
                     39: NULL
                     40: 
                     41: Warning: hash_hmac_file() expects at least 3 parameters, 1 given in %s on line %d
                     42: NULL
                     43: 
                     44: Warning: hash_hmac_file() expects at least 3 parameters, 2 given in %s on line %d
                     45: NULL
                     46: 
                     47: -- Testing hash_hmac_file() function with more than expected no. of arguments --
                     48: 
                     49: Warning: hash_hmac_file() expects at most 4 parameters, 5 given in %s on line %d
                     50: 
                     51: -- Testing hash_hmac_file() function with invalid hash algorithm --
                     52: 
                     53: Warning: hash_hmac_file(): Unknown hashing algorithm: foo in %s on line %d
                     54: ===Done===

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