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
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
38Warning: hash_hmac_file() expects at least 3 parameters, 0 given in %s on line %d
39NULL
40
41Warning: hash_hmac_file() expects at least 3 parameters, 1 given in %s on line %d
42NULL
43
44Warning: hash_hmac_file() expects at least 3 parameters, 2 given in %s on line %d
45NULL
46
47-- Testing hash_hmac_file() function with more than expected no. of arguments --
48
49Warning: 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
53Warning: hash_hmac_file(): Unknown hashing algorithm: foo in %s on line %d
54===Done===