each_error.phpt 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. Test each() function : error conditions - pass incorrect number of args
  3. --FILE--
  4. <?php
  5. /* Prototype : array each(array $arr)
  6. * Description: Return the currently pointed key..value pair in the passed array,
  7. * and advance the pointer to the next element
  8. * Source code: Zend/zend_builtin_functions.c
  9. */
  10. /*
  11. * Pass an incorrect number of arguments to each() to test behaviour
  12. */
  13. echo "*** Testing each() : error conditions ***\n";
  14. // Zero arguments
  15. echo "\n-- Testing each() function with Zero arguments --\n";
  16. var_dump( each() );
  17. //Test each with one more than the expected number of arguments
  18. echo "\n-- Testing each() function with more than expected no. of arguments --\n";
  19. $arr = array(1, 2);
  20. $extra_arg = 10;
  21. var_dump( each($arr, $extra_arg) );
  22. echo "Done";
  23. ?>
  24. --EXPECTF--
  25. *** Testing each() : error conditions ***
  26. -- Testing each() function with Zero arguments --
  27. Warning: each() expects exactly 1 parameter, 0 given in %s on line %d
  28. NULL
  29. -- Testing each() function with more than expected no. of arguments --
  30. Warning: each() expects exactly 1 parameter, 2 given in %s on line %d
  31. NULL
  32. Done