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