mb_strtolower_error1.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. Test mb_strtolower() function : error conditions - pass incorrect number of arguments
  3. --SKIPIF--
  4. <?php
  5. extension_loaded('mbstring') or die('skip');
  6. function_exists('mb_strtolower') or die("skip mb_strtolower() is not available in this build");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Prototype : string mb_strtolower(string $sourcestring [, string $encoding])
  11. * Description: Returns a lowercased version of $sourcestring
  12. * Source code: ext/mbstring/mbstring.c
  13. */
  14. /*
  15. * Pass an incorrect number of arguments to mb_strtolower() to test behaviour
  16. */
  17. echo "*** Testing mb_strtolower() : error conditions***\n";
  18. //Test mb_strtolower with one more than the expected number of arguments
  19. echo "\n-- Testing mb_strtolower() function with more than expected no. of arguments --\n";
  20. $sourcestring = 'string_value';
  21. $encoding = 'UTF-8';
  22. $extra_arg = 10;
  23. var_dump( mb_strtolower($sourcestring, $encoding, $extra_arg) );
  24. //Test mb_strtolower with zero arguments
  25. echo "\n-- Testing mb_strtolower() function with zero arguments --\n";
  26. var_dump( mb_strtolower() );
  27. echo "Done";
  28. ?>
  29. --EXPECTF--
  30. *** Testing mb_strtolower() : error conditions***
  31. -- Testing mb_strtolower() function with more than expected no. of arguments --
  32. Warning: mb_strtolower() expects at most 2 parameters, 3 given in %s on line %d
  33. NULL
  34. -- Testing mb_strtolower() function with zero arguments --
  35. Warning: mb_strtolower() expects at least 1 parameter, 0 given in %s on line %d
  36. NULL
  37. Done