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