Annotation of embedaddon/php/ext/hash/tests/hash_hmac_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test hash_hmac() function : basic functionality
3: --SKIPIF--
4: <?php extension_loaded('hash') or die('skip: hash extension not loaded.'); ?>
5: --FILE--
6: <?php
7: /*
8: * proto string hash_hmac ( string algo, string data, string key [, bool raw_output] )
9: * Function is implemented in ext/hash/hash.c
10: */
11:
12: echo "*** Testing hash_hmac() : error conditions ***\n";
13:
14: $data = "This is a sample string used to test the hash_hmac function with various hashing algorithms";
15: $key = 'secret';
16:
17: echo "\n-- Testing hash_hmac() function with less than expected no. of arguments --\n";
18: var_dump(hash_hmac());
19: var_dump(hash_hmac('crc32'));
20: var_dump(hash_hmac('crc32', $data));
21:
22: echo "\n-- Testing hash_hmac() function with more than expected no. of arguments --\n";
23: $extra_arg = 10;
24: var_dump(hash_hmac('crc32', $data, $key, TRUE, $extra_arg));
25:
26: echo "\n-- Testing hash_hmac() function with invalid hash algorithm --\n";
27: var_dump(hash_hmac('foo', $data, $key));
28:
29: ?>
30: ===Done===
31: --EXPECTF--
32: *** Testing hash_hmac() : error conditions ***
33:
34: -- Testing hash_hmac() function with less than expected no. of arguments --
35:
36: Warning: hash_hmac() expects at least 3 parameters, 0 given in %s on line %d
37: NULL
38:
39: Warning: hash_hmac() expects at least 3 parameters, 1 given in %s on line %d
40: NULL
41:
42: Warning: hash_hmac() expects at least 3 parameters, 2 given in %s on line %d
43: NULL
44:
45: -- Testing hash_hmac() function with more than expected no. of arguments --
46:
47: Warning: hash_hmac() expects at most 4 parameters, 5 given in %s on line %d
48: NULL
49:
50: -- Testing hash_hmac() function with invalid hash algorithm --
51:
52: Warning: hash_hmac(): Unknown hashing algorithm: foo in %s on line %d
53: bool(false)
54: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>