php-src/ext/standard/tests/array/key_error.phpt
2008-02-21 14:34:41 +00:00

40 lines
1.1 KiB
PHP

--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===