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