xref: /PHP-7.3/ext/hash/tests/hash_equals.phpt (revision ce1d69a1)
1--TEST--
2hash_equals() function
3--SKIPIF--
4<?php if(!extension_loaded('hash')) die('skip hash extension not loaded'); ?>
5--FILE--
6<?php
7var_dump(hash_equals("same", "same"));
8var_dump(hash_equals("not1same", "not2same"));
9var_dump(hash_equals("short", "longer"));
10var_dump(hash_equals("longer", "short"));
11var_dump(hash_equals("", "notempty"));
12var_dump(hash_equals("notempty", ""));
13var_dump(hash_equals("", ""));
14var_dump(hash_equals(123, "NaN"));
15var_dump(hash_equals("NaN", 123));
16var_dump(hash_equals(123, 123));
17var_dump(hash_equals(null, ""));
18var_dump(hash_equals(null, 123));
19var_dump(hash_equals(null, null));
20?>
21--EXPECTF--
22bool(true)
23bool(false)
24bool(false)
25bool(false)
26bool(false)
27bool(false)
28bool(true)
29
30Warning: hash_equals(): Expected known_string to be a string, int given in %s on line %d
31bool(false)
32
33Warning: hash_equals(): Expected user_string to be a string, int given in %s on line %d
34bool(false)
35
36Warning: hash_equals(): Expected known_string to be a string, int given in %s on line %d
37bool(false)
38
39Warning: hash_equals(): Expected known_string to be a string, null given in %s on line %d
40bool(false)
41
42Warning: hash_equals(): Expected known_string to be a string, null given in %s on line %d
43bool(false)
44
45Warning: hash_equals(): Expected known_string to be a string, null given in %s on line %d
46bool(false)
47