1--TEST-- 2Test 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 14echo "*** Testing hash() : error conditions ***\n"; 15 16$file = dirname(__FILE__) . "hash_file.txt"; 17$key = 'secret'; 18 19echo "\n-- Testing hash_hmac_file() function with less than expected no. of arguments --\n"; 20var_dump(hash_hmac_file()); 21var_dump(hash_hmac_file('crc32')); 22var_dump(hash_hmac_file('crc32', $file)); 23 24echo "\n-- Testing hash_hmac_file() function with more than expected no. of arguments --\n"; 25$extra_arg = 10; 26hash_hmac_file('crc32', $file, $key, TRUE, $extra_arg); 27 28echo "\n-- Testing hash_hmac_file() function with invalid hash algorithm --\n"; 29hash_hmac_file('foo', $file, $key, TRUE); 30 31echo "\n-- Testing hash_hmac_file() function with non-cryptographic hash algorithm --\n"; 32hash_hmac_file('crc32', $file, $key, TRUE); 33 34echo "\n-- Testing hash_hmac_file() function with bad path --\n"; 35hash_hmac_file('md5', $file.chr(0).$file, $key, TRUE); 36 37?> 38===Done=== 39--EXPECTF-- 40*** Testing hash() : error conditions *** 41 42-- Testing hash_hmac_file() function with less than expected no. of arguments -- 43 44Warning: hash_hmac_file() expects at least 3 parameters, 0 given in %s on line %d 45NULL 46 47Warning: hash_hmac_file() expects at least 3 parameters, 1 given in %s on line %d 48NULL 49 50Warning: hash_hmac_file() expects at least 3 parameters, 2 given in %s on line %d 51NULL 52 53-- Testing hash_hmac_file() function with more than expected no. of arguments -- 54 55Warning: hash_hmac_file() expects at most 4 parameters, 5 given in %s on line %d 56 57-- Testing hash_hmac_file() function with invalid hash algorithm -- 58 59Warning: hash_hmac_file(): Unknown hashing algorithm: foo in %s on line %d 60 61-- Testing hash_hmac_file() function with non-cryptographic hash algorithm -- 62 63Warning: hash_hmac_file(): Non-cryptographic hashing algorithm: crc32 in %s on line %d 64 65-- Testing hash_hmac_file() function with bad path -- 66 67Warning: hash_hmac_file(): Invalid path in %s on line %d 68===Done=== 69