opendir_basic.phpt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. Test opendir() function : basic functionality
  3. --FILE--
  4. <?php
  5. /*
  6. * Test basic functionality of opendir() with absolute and relative paths as $path argument
  7. */
  8. echo "*** Testing opendir() : basic functionality ***\n";
  9. $base_dir_path = __DIR__ . '/opendir_basic';
  10. @mkdir($base_dir_path);
  11. $level_one_dir_name = "level_one";
  12. $level_one_dir_path = "$base_dir_path/$level_one_dir_name";
  13. $level_two_dir_name = "level_two";
  14. $level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name";
  15. // create temporary directories - will remove in CLEAN section
  16. mkdir($level_one_dir_path);
  17. mkdir($level_two_dir_path);
  18. echo "\n-- Testing opendir() with absolute path: --\n";
  19. var_dump($dh1 = opendir($level_one_dir_path));
  20. echo "\n-- Testing opendir() with relative paths: --\n";
  21. var_dump(chdir($level_one_dir_path));
  22. var_dump($dh2 = opendir($level_two_dir_name));
  23. echo "\n-- Close directory handles: --\n";
  24. closedir($dh1);
  25. var_dump($dh1);
  26. closedir($dh2);
  27. var_dump($dh2);
  28. ?>
  29. --CLEAN--
  30. <?php
  31. $base_dir_path = __DIR__ . '/opendir_basic';
  32. rmdir("$base_dir_path/level_one/level_two");
  33. rmdir("$base_dir_path/level_one");
  34. rmdir($base_dir_path);
  35. ?>
  36. --EXPECTF--
  37. *** Testing opendir() : basic functionality ***
  38. -- Testing opendir() with absolute path: --
  39. resource(%d) of type (stream)
  40. -- Testing opendir() with relative paths: --
  41. bool(true)
  42. resource(%d) of type (stream)
  43. -- Close directory handles: --
  44. resource(%d) of type (Unknown)
  45. resource(%d) of type (Unknown)