Annotation of embedaddon/php/ext/hash/tests/hash_error.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test 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: */
! 13: echo "*** Testing hash() : error conditions ***\n";
! 14:
! 15: echo "\n-- Testing hash() function with less than expected no. of arguments --\n";
! 16: var_dump(hash());
! 17: var_dump(hash('adler32'));
! 18:
! 19: echo "\n-- Testing hash() function with more than expected no. of arguments --\n";
! 20: $extra_arg= 10;
! 21: var_dump(hash('adler32', '', false, $extra_arg));
! 22:
! 23: echo "\n-- Testing hash() function with invalid hash algorithm --\n";
! 24: var_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:
! 33: Warning: hash() expects at least 2 parameters, 0 given in %s on line %d
! 34: NULL
! 35:
! 36: Warning: hash() expects at least 2 parameters, 1 given in %s on line %d
! 37: NULL
! 38:
! 39: -- Testing hash() function with more than expected no. of arguments --
! 40:
! 41: Warning: hash() expects at most 3 parameters, 4 given in %s on line %d
! 42: NULL
! 43:
! 44: -- Testing hash() function with invalid hash algorithm --
! 45:
! 46: Warning: hash(): Unknown hashing algorithm: foo in %s on line %d
! 47: bool(false)
! 48: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>