dir_variation6.phpt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. Test dir() function : usage variations - non-existent directory
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) == 'WIN') {
  6. die('skip.. Not valid for Windows');
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. /*
  12. * Passing a non-existent directory as argument to dir() function
  13. * and checking to see if proper warning message is output.
  14. */
  15. echo "*** Testing dir() : open a non-existent directory ***\n";
  16. // create the temporary directory
  17. $file_path = __DIR__;
  18. $dir_path = $file_path."/dir_variation6";
  19. @mkdir($dir_path);
  20. // open existent directory
  21. $d = dir($dir_path);
  22. $d->close(); //close the dir
  23. // remove directory and try to open the same(non-existent) directory again
  24. rmdir($dir_path);
  25. clearstatcache();
  26. echo "-- opening previously removed directory --\n";
  27. var_dump( dir($dir_path) );
  28. // point to a non-existent directory
  29. $non_existent_dir = $file_path."/non_existent_dir";
  30. echo "-- opening non-existent directory --\n";
  31. $d = dir($non_existent_dir);
  32. var_dump( $d );
  33. echo "Done";
  34. ?>
  35. --EXPECTF--
  36. *** Testing dir() : open a non-existent directory ***
  37. -- opening previously removed directory --
  38. Warning: dir(%s): Failed to open directory: %s in %s on line %d
  39. bool(false)
  40. -- opening non-existent directory --
  41. Warning: dir(%s): Failed to open directory: %s in %s on line %d
  42. bool(false)
  43. Done