Annotation of embedaddon/php/ext/standard/tests/array/array_key_exists_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_key_exists() function : error conditions - Pass incorrect number of args
3: --FILE--
4: <?php
5: /* Prototype : bool array_key_exists(mixed $key, array $search)
6: * Description: Checks if the given key or index exists in the array
7: * Source code: ext/standard/array.c
8: * Alias to functions: key_exists
9: */
10:
11: /*
12: * Pass incorrect number of arguments to array_key_exists() to test behaviour
13: */
14:
15: echo "*** Testing array_key_exists() : error conditions ***\n";
16:
17: //Test array_key_exists with one more than the expected number of arguments
18: echo "\n-- Testing array_key_exists() function with more than expected no. of arguments --\n";
19: $key = 1;
20: $search = array(1, 2);
21: $extra_arg = 10;
22: var_dump( array_key_exists($key, $search, $extra_arg) );
23:
24: // Testing array_key_exists with one less than the expected number of arguments
25: echo "\n-- Testing array_key_exists() function with less than expected no. of arguments --\n";
26: $key = 1;
27: var_dump( array_key_exists($key) );
28:
29: echo "Done";
30: ?>
31:
32: --EXPECTF--
33: *** Testing array_key_exists() : error conditions ***
34:
35: -- Testing array_key_exists() function with more than expected no. of arguments --
36:
37: Warning: array_key_exists() expects exactly 2 parameters, 3 given in %s on line %d
38: NULL
39:
40: -- Testing array_key_exists() function with less than expected no. of arguments --
41:
42: Warning: array_key_exists() expects exactly 2 parameters, 1 given in %s on line %d
43: NULL
44: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>