Annotation of embedaddon/php/ext/standard/tests/array/key_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test key() function : error conditions - Pass incorrect number of args
3: --FILE--
4: <?php
5: /* Prototype : mixed key(array $array_arg)
6: * Description: Return the key of the element currently pointed to by the internal array pointer
7: * Source code: ext/standard/array.c
8: */
9:
10: /*
11: * Pass incorrect number of arguments to key() to test behaviour
12: */
13:
14: echo "*** Testing key() : error conditions ***\n";
15:
16: // Zero arguments
17: echo "\n-- Testing key() function with Zero arguments --\n";
18: var_dump( key() );
19:
20: //Test current with one more than the expected number of arguments
21: echo "\n-- Testing key() function with more than expected no. of arguments --\n";
22: $array_arg = array(1, 2);
23: $extra_arg = 10;
24: var_dump( key($array_arg, $extra_arg) );
25: ?>
26: ===DONE===
27: --EXPECTF--
28: *** Testing key() : error conditions ***
29:
30: -- Testing key() function with Zero arguments --
31:
32: Warning: key() expects exactly 1 parameter, 0 given in %s on line %d
33: NULL
34:
35: -- Testing key() function with more than expected no. of arguments --
36:
37: Warning: key() expects exactly 1 parameter, 2 given in %s on line %d
38: NULL
39: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>