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