1--TEST--
2Hash: hash_hmac_file() function : basic functionality
3--FILE--
4<?php
5
6echo "*** Testing hash() : error conditions ***\n";
7
8$file = __DIR__ . "hash_file.txt";
9$key = 'secret';
10
11echo "\n-- Testing hash_hmac_file() function with invalid hash algorithm --\n";
12try {
13    var_dump(hash_hmac_file('foo', $file, $key, TRUE));
14}
15catch (\Error $e) {
16    echo $e->getMessage() . "\n";
17}
18
19echo "\n-- Testing hash_hmac_file() function with non-cryptographic hash algorithm --\n";
20try {
21    var_dump(hash_hmac_file('crc32', $file, $key, TRUE));
22}
23catch (\Error $e) {
24    echo $e->getMessage() . "\n";
25}
26
27echo "\n-- Testing hash_hmac_file() function with bad path --\n";
28try {
29    var_dump(hash_hmac_file('md5', $file.chr(0).$file, $key, TRUE));
30}
31catch (ValueError $e) {
32    echo $e->getMessage() . "\n";
33}
34
35?>
36--EXPECT--
37*** Testing hash() : error conditions ***
38
39-- Testing hash_hmac_file() function with invalid hash algorithm --
40hash_hmac_file(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
41
42-- Testing hash_hmac_file() function with non-cryptographic hash algorithm --
43hash_hmac_file(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
44
45-- Testing hash_hmac_file() function with bad path --
46hash_hmac_file(): Argument #2 ($filename) must not contain any null bytes
47