dir_basic-win32-mb.phpt 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. --TEST--
  2. Test dir() function : basic functionality
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) != 'WIN') {
  6. die("skip Valid only on Windows");
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. echo "*** Testing dir() : basic functionality ***\n";
  12. // include the file.inc for Function: function create_files()
  13. include(__DIR__."/../file/file.inc");
  14. // create the temporary directory
  15. $file_path = __DIR__;
  16. $dir_path = $file_path."/私はガラスを食べられますdir_basic";
  17. @mkdir($dir_path);
  18. // create files within the temporary directory
  19. create_files($dir_path, 3, "alphanumeric", 0755, 1, "w", "私はガラスを食べられますdir_basic");
  20. echo "Get Directory instance:\n";
  21. $d = dir($dir_path);
  22. var_dump( $d );
  23. echo "\nRead and rewind:\n";
  24. var_dump( $d->read() );
  25. var_dump( $d->read() );
  26. var_dump( $d->rewind() );
  27. echo "\nTest using handle directly:\n";
  28. var_dump( readdir($d->handle) );
  29. var_dump( readdir($d->handle) );
  30. echo "\nClose directory:\n";
  31. var_dump( $d->close() );
  32. var_dump( $d );
  33. echo "\nTest read after closing the dir:\n";
  34. try {
  35. var_dump( $d->read() );
  36. } catch (TypeError $e) {
  37. echo $e->getMessage(), "\n";
  38. }
  39. // delete temp files
  40. delete_files($dir_path, 3, "私はガラスを食べられますdir_basic", 1, ".tmp");
  41. echo "Done";
  42. ?>
  43. --CLEAN--
  44. <?php
  45. $file_path = __DIR__;
  46. $dir_path = $file_path."/私はガラスを食べられますdir_basic";
  47. rmdir($dir_path);
  48. ?>
  49. --EXPECTF--
  50. *** Testing dir() : basic functionality ***
  51. Get Directory instance:
  52. object(Directory)#%d (2) {
  53. ["path"]=>
  54. string(%d) "%s/私はガラスを食べられますdir_basic"
  55. ["handle"]=>
  56. resource(%d) of type (stream)
  57. }
  58. Read and rewind:
  59. string(%d) "%s"
  60. string(%d) "%s"
  61. NULL
  62. Test using handle directly:
  63. string(%d) "%s"
  64. string(%d) "%s"
  65. Close directory:
  66. NULL
  67. object(Directory)#%d (2) {
  68. ["path"]=>
  69. string(%d) "%s私はガラスを食べられますdir_basic"
  70. ["handle"]=>
  71. resource(%d) of type (Unknown)
  72. }
  73. Test read after closing the dir:
  74. Directory::read(): %s is not a valid Directory resource
  75. Done