diff options
Diffstat (limited to 'ext/standard/tests/array/key_error.phpt')
-rw-r--r-- | ext/standard/tests/array/key_error.phpt | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/ext/standard/tests/array/key_error.phpt b/ext/standard/tests/array/key_error.phpt new file mode 100644 index 0000000..1200f74 --- /dev/null +++ b/ext/standard/tests/array/key_error.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test key() function : error conditions - Pass incorrect number of args +--FILE-- +<?php +/* Prototype : mixed key(array $array_arg) + * Description: Return the key of the element currently pointed to by the internal array pointer + * Source code: ext/standard/array.c + */ + +/* + * Pass incorrect number of arguments to key() to test behaviour + */ + +echo "*** Testing key() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing key() function with Zero arguments --\n"; +var_dump( key() ); + +//Test current with one more than the expected number of arguments +echo "\n-- Testing key() function with more than expected no. of arguments --\n"; +$array_arg = array(1, 2); +$extra_arg = 10; +var_dump( key($array_arg, $extra_arg) ); +?> +===DONE=== +--EXPECTF-- +*** Testing key() : error conditions *** + +-- Testing key() function with Zero arguments -- + +Warning: key() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing key() function with more than expected no. of arguments -- + +Warning: key() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== |