1--TEST--
2Test rewinddir() function : basic functionality
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/*
12 * Test basic functionality of rewinddir()
13 */
14
15echo "*** Testing rewinddir() : basic functionality ***\n";
16
17// include file.inc for create_files function
18include(__DIR__ . "/../file/file.inc");
19
20$dir_path1 = __DIR__ . "/私はガラスを食べられますrewinddir_basic_dir1";
21$dir_path2 = __DIR__ . "/私はガラスを食べられますrewinddir_basic_dir2";
22mkdir($dir_path1);
23mkdir($dir_path2);
24
25@create_files($dir_path1, 1, "numeric", 0755, 1, "w", "私はガラスを食べられますfile");
26@create_files($dir_path2, 1, 'numeric', 0755, 1, 'w', "私はガラスを食べられますfile", 2);
27var_dump($dh1 = opendir($dir_path1));
28var_dump($dh2 = opendir($dir_path2));
29
30$data = array();
31echo "\n-- Read and rewind first directory (argument supplied) --\n";
32while(FALSE !== $file1 = readdir($dh1)) {
33    $data[] = $file1;
34}
35$first = $data[0];
36sort($data);
37var_dump($data);
38
39var_dump(rewinddir($dh1));
40var_dump(readdir($dh1) == $first);
41
42$data = array();
43echo "\n-- Read and rewind second directory (no argument supplied) --\n";
44while(FALSE !== $file2 = readdir()) {
45    $data[] = $file2;
46}
47$first = $data[0];
48sort($data);
49var_dump($data);
50
51var_dump(rewinddir());
52var_dump(readdir() == $first);
53
54closedir($dh1);
55closedir($dh2);
56
57delete_files($dir_path1, 1, "私はガラスを食べられますfile");
58delete_files($dir_path2, 1, "私はガラスを食べられますfile", 2);
59?>
60--CLEAN--
61<?php
62$dir_path1 = __DIR__ . "/私はガラスを食べられますrewinddir_basic_dir1";
63$dir_path2 = __DIR__ . "/私はガラスを食べられますrewinddir_basic_dir2";
64rmdir($dir_path1);
65rmdir($dir_path2);
66?>
67--EXPECTF--
68*** Testing rewinddir() : basic functionality ***
69resource(%d) of type (stream)
70resource(%d) of type (stream)
71
72-- Read and rewind first directory (argument supplied) --
73array(3) {
74  [0]=>
75  string(1) "."
76  [1]=>
77  string(2) ".."
78  [2]=>
79  string(45) "私はガラスを食べられますfile1.tmp"
80}
81NULL
82bool(true)
83
84-- Read and rewind second directory (no argument supplied) --
85array(3) {
86  [0]=>
87  string(1) "."
88  [1]=>
89  string(2) ".."
90  [2]=>
91  string(45) "私はガラスを食べられますfile2.tmp"
92}
93NULL
94bool(true)
95