current_error.phpt 1.1 KB

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