xref: /PHP-5.3/ext/hash/tests/hash_error.phpt (revision c41cc6aa)
1--TEST--
2Test hash() function : error conditions
3--SKIPIF--
4<?php extension_loaded('hash') or die('skip: hash extension not loaded.'); ?>
5--FILE--
6<?php
7
8/* Prototype  : string hash  ( string $algo  , string $data  [, bool $raw_output  ] )
9 * Description: Generate a hash value (message digest)
10 * Source code: ext/hash/hash.c
11 * Alias to functions:
12*/
13echo "*** Testing hash() : error conditions ***\n";
14
15echo "\n-- Testing hash() function with less than expected no. of arguments --\n";
16var_dump(hash());
17var_dump(hash('adler32'));
18
19echo "\n-- Testing hash() function with more than expected no. of arguments --\n";
20$extra_arg= 10;
21var_dump(hash('adler32', '', false, $extra_arg));
22
23echo "\n-- Testing hash() function with invalid hash algorithm --\n";
24var_dump(hash('foo', ''));
25
26?>
27===Done===
28--EXPECTF--
29*** Testing hash() : error conditions ***
30
31-- Testing hash() function with less than expected no. of arguments --
32
33Warning: hash() expects at least 2 parameters, 0 given in %s on line %d
34NULL
35
36Warning: hash() expects at least 2 parameters, 1 given in %s on line %d
37NULL
38
39-- Testing hash() function with more than expected no. of arguments --
40
41Warning: hash() expects at most 3 parameters, 4 given in %s on line %d
42NULL
43
44-- Testing hash() function with invalid hash algorithm --
45
46Warning: hash(): Unknown hashing algorithm: foo in %s on line %d
47bool(false)
48===Done===