readdir_variation4-win32-mb.phpt 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. --TEST--
  2. Test readdir() function : usage variations - different file names
  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. /*
  12. * Pass a directory handle pointing to a directory that contains
  13. * files with different file names to test how readdir() reads them
  14. */
  15. echo "*** Testing readdir() : usage variations ***\n";
  16. $dir_path = __DIR__ . "/私はガラスを食べられますreaddir_variation4/";
  17. mkdir($dir_path);
  18. // heredoc string
  19. $heredoc = <<<EOT
  20. hd_file
  21. EOT;
  22. $inputs = array(
  23. // int data
  24. /*1*/ 0,
  25. 1,
  26. 12345,
  27. -2345,
  28. // float data
  29. /*5*/ 10.5,
  30. -10.5,
  31. 12.3456789000e10,
  32. 12.3456789000E-10,
  33. .5,
  34. // empty data
  35. /*10*/ "",
  36. array(),
  37. // string data
  38. /*12*/ "double_file",
  39. 'single_file',
  40. $heredoc,
  41. );
  42. $iterator = 1;
  43. foreach($inputs as $key => $input) {
  44. echo "\n-- Iteration $iterator --\n";
  45. $handle = "fp{$iterator}";
  46. var_dump( $$handle = @fopen($dir_path . "私はガラスを食べられます$input.tmp", 'w') );
  47. var_dump( fwrite($$handle, $key));
  48. fclose($$handle);
  49. $iterator++;
  50. };
  51. echo "\n-- Call to readdir() --\n";
  52. $dir_handle = opendir($dir_path);
  53. while(FALSE !== ($file = readdir($dir_handle))){
  54. // different OS order files differently so will
  55. // store file names into an array so can use sorted in expected output
  56. $contents[] = $file;
  57. // remove files while going through directory
  58. @unlink($dir_path . $file);
  59. }
  60. // more important to check that all contents are present than order they are returned in
  61. sort($contents);
  62. var_dump($contents);
  63. closedir($dir_handle);
  64. ?>
  65. --CLEAN--
  66. <?php
  67. $dir_path = __DIR__ . "/私はガラスを食べられますreaddir_variation4/";
  68. rmdir($dir_path);
  69. ?>
  70. --EXPECTF--
  71. *** Testing readdir() : usage variations ***
  72. -- Iteration 1 --
  73. resource(%d) of type (stream)
  74. int(1)
  75. -- Iteration 2 --
  76. resource(%d) of type (stream)
  77. int(1)
  78. -- Iteration 3 --
  79. resource(%d) of type (stream)
  80. int(1)
  81. -- Iteration 4 --
  82. resource(%d) of type (stream)
  83. int(1)
  84. -- Iteration 5 --
  85. resource(%d) of type (stream)
  86. int(1)
  87. -- Iteration 6 --
  88. resource(%d) of type (stream)
  89. int(1)
  90. -- Iteration 7 --
  91. resource(%d) of type (stream)
  92. int(1)
  93. -- Iteration 8 --
  94. resource(%d) of type (stream)
  95. int(1)
  96. -- Iteration 9 --
  97. resource(%d) of type (stream)
  98. int(1)
  99. -- Iteration 10 --
  100. resource(%d) of type (stream)
  101. int(1)
  102. -- Iteration 11 --
  103. resource(%d) of type (stream)
  104. int(2)
  105. -- Iteration 12 --
  106. resource(%d) of type (stream)
  107. int(2)
  108. -- Iteration 13 --
  109. resource(%d) of type (stream)
  110. int(2)
  111. -- Iteration 14 --
  112. resource(%d) of type (stream)
  113. int(2)
  114. -- Call to readdir() --
  115. array(16) {
  116. [0]=>
  117. string(1) "."
  118. [1]=>
  119. string(2) ".."
  120. [2]=>
  121. string(45) "私はガラスを食べられます-10.5.tmp"
  122. [3]=>
  123. string(45) "私はガラスを食べられます-2345.tmp"
  124. [4]=>
  125. string(40) "私はガラスを食べられます.tmp"
  126. [5]=>
  127. string(43) "私はガラスを食べられます0.5.tmp"
  128. [6]=>
  129. string(41) "私はガラスを食べられます0.tmp"
  130. [7]=>
  131. string(53) "私はガラスを食べられます1.23456789E-9.tmp"
  132. [8]=>
  133. string(41) "私はガラスを食べられます1.tmp"
  134. [9]=>
  135. string(44) "私はガラスを食べられます10.5.tmp"
  136. [10]=>
  137. string(45) "私はガラスを食べられます12345.tmp"
  138. [11]=>
  139. string(52) "私はガラスを食べられます123456789000.tmp"
  140. [12]=>
  141. string(45) "私はガラスを食べられますArray.tmp"
  142. [13]=>
  143. string(51) "私はガラスを食べられますdouble_file.tmp"
  144. [14]=>
  145. string(47) "私はガラスを食べられますhd_file.tmp"
  146. [15]=>
  147. string(51) "私はガラスを食べられますsingle_file.tmp"
  148. }