Annotation of embedaddon/php/ext/standard/tests/array/in_array_errors.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test in_array() function : error conditions
! 3: --FILE--
! 4: <?php
! 5: /*
! 6: * Prototype : bool in_array ( mixed $needle, array $haystack [, bool $strict] )
! 7: * Description: Searches haystack for needle and returns TRUE
! 8: * if it is found in the array, FALSE otherwise.
! 9: * Source Code: ext/standard/array.c
! 10: */
! 11:
! 12: echo "\n*** Testing error conditions of in_array() ***\n";
! 13: /* zero argument */
! 14: var_dump( in_array() );
! 15:
! 16: /* unexpected no.of arguments in in_array() */
! 17: $var = array("mon", "tues", "wed", "thurs");
! 18: var_dump( in_array(1, $var, 0, "test") );
! 19: var_dump( in_array("test") );
! 20:
! 21: /* unexpected second argument in in_array() */
! 22: $var="test";
! 23: var_dump( in_array("test", $var) );
! 24: var_dump( in_array(1, 123) );
! 25:
! 26: echo "Done\n";
! 27: ?>
! 28: --EXPECTF--
! 29: *** Testing error conditions of in_array() ***
! 30:
! 31: Warning: in_array() expects at least 2 parameters, 0 given in %s on line %d
! 32: NULL
! 33:
! 34: Warning: in_array() expects at most 3 parameters, 4 given in %s on line %d
! 35: NULL
! 36:
! 37: Warning: in_array() expects at least 2 parameters, 1 given in %s on line %d
! 38: NULL
! 39:
! 40: Warning: in_array() expects parameter 2 to be array, string given in %s on line %d
! 41: NULL
! 42:
! 43: Warning: in_array() expects parameter 2 to be array, integer given in %s on line %d
! 44: NULL
! 45: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>