1--TEST-- 2hash_init() function - errors test 3--SKIPIF-- 4<?php 5if (!extension_loaded('hash')) die('skip hash extension not available'); 6?> 7--FILE-- 8<?php 9echo "*** Testing hash_init(): error conditions ***\n"; 10 11echo "-- Testing hash_init() function with no parameters --\n"; 12var_dump(hash_init()); 13 14echo "-- Testing hash_init() function with unknown algorithms --\n"; 15var_dump(hash_init('dummy')); 16 17echo "-- Testing hash_init() function with HASH_HMAC and non-cryptographic algorithms --\n"; 18var_dump(hash_init('crc32', HASH_HMAC)); 19 20echo "-- Testing hash_init() function with HASH_HMAC and no key --\n"; 21var_dump(hash_init('md5', HASH_HMAC)); 22var_dump(hash_init('md5', HASH_HMAC, null)); 23?> 24--EXPECTF-- 25*** Testing hash_init(): error conditions *** 26-- Testing hash_init() function with no parameters -- 27 28Warning: hash_init() expects at least 1 parameter, 0 given in %s on line %d 29NULL 30-- Testing hash_init() function with unknown algorithms -- 31 32Warning: hash_init(): Unknown hashing algorithm: dummy in %s on line %d 33bool(false) 34-- Testing hash_init() function with HASH_HMAC and non-cryptographic algorithms -- 35 36Warning: hash_init(): HMAC requested with a non-cryptographic hashing algorithm: crc32 in %s on line %d 37bool(false) 38-- Testing hash_init() function with HASH_HMAC and no key -- 39 40Warning: hash_init(): HMAC requested without a key %s on line %d 41bool(false) 42 43Warning: hash_init(): HMAC requested without a key %s on line %d 44bool(false) 45