next_error.phpt 1.1 KB

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