readdir_error.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. Test readdir() function : error conditions - Incorrect number of args
  3. --FILE--
  4. <?php
  5. /* Prototype : string readdir([resource $dir_handle])
  6. * Description: Read directory entry from dir_handle
  7. * Source code: ext/standard/dir.c
  8. */
  9. /*
  10. * Pass incorrect number of arguments to readdir() to test behaviour
  11. */
  12. echo "*** Testing readdir() : error conditions ***\n";
  13. //Test readdir with one more than the expected number of arguments
  14. echo "\n-- Testing readdir() function with more than expected no. of arguments --\n";
  15. $path = dirname(__FILE__) . "/readdir_error";
  16. mkdir($path);
  17. $dir_handle = opendir($path);
  18. $extra_arg = 10;
  19. var_dump( readdir($dir_handle, $extra_arg) );
  20. // close the handle so can remove dir in CLEAN section
  21. closedir($dir_handle);
  22. ?>
  23. ===DONE===
  24. --CLEAN--
  25. <?php
  26. $path = dirname(__FILE__) . "/readdir_error";
  27. rmdir($path);
  28. ?>
  29. --EXPECTF--
  30. *** Testing readdir() : error conditions ***
  31. -- Testing readdir() function with more than expected no. of arguments --
  32. Warning: readdir() expects at most 1 parameter, 2 given in %s on line %d
  33. NULL
  34. ===DONE===