readdir_basic.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. --TEST--
  2. Test readdir() function : basic functionality
  3. --FILE--
  4. <?php
  5. /*
  6. * Test basic functionality of readdir()
  7. */
  8. echo "*** Testing readdir() : basic functionality ***\n";
  9. // include the file.inc for Function: function create_files()
  10. chdir(__DIR__);
  11. include(__DIR__."/../file/file.inc");
  12. $path = __DIR__ . '/readdir_basic';
  13. mkdir($path);
  14. create_files($path, 3);
  15. echo "\n-- Call readdir() with \$path argument --\n";
  16. var_dump($dh = opendir($path));
  17. $a = array();
  18. while( FALSE !== ($file = readdir($dh)) ) {
  19. $a[] = $file;
  20. }
  21. sort($a);
  22. foreach($a as $file) {
  23. var_dump($file);
  24. }
  25. echo "\n-- Call readdir() without \$path argument --\n";
  26. var_dump($dh = opendir($path));
  27. $a = array();
  28. while( FALSE !== ( $file = readdir() ) ) {
  29. $a[] = $file;
  30. }
  31. sort($a);
  32. foreach($a as $file) {
  33. var_dump($file);
  34. }
  35. delete_files($path, 3);
  36. closedir($dh);
  37. ?>
  38. --CLEAN--
  39. <?php
  40. $path = __DIR__ . '/readdir_basic';
  41. rmdir($path);
  42. ?>
  43. --EXPECTF--
  44. *** Testing readdir() : basic functionality ***
  45. -- Call readdir() with $path argument --
  46. resource(%d) of type (stream)
  47. string(1) "."
  48. string(2) ".."
  49. string(9) "file1.tmp"
  50. string(9) "file2.tmp"
  51. string(9) "file3.tmp"
  52. -- Call readdir() without $path argument --
  53. resource(%d) of type (stream)
  54. string(1) "."
  55. string(2) ".."
  56. string(9) "file1.tmp"
  57. string(9) "file2.tmp"
  58. string(9) "file3.tmp"