1--TEST--
2Test opendir() function : usage variations - different relative paths
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 opendir() with different relative paths as $path argument
13 */
14
15echo "*** Testing opendir() : usage variation ***\n";
16
17$base_dir_path = __DIR__ . '/opendir_variation4-win32-mb';
18@mkdir($base_dir_path);
19
20$level_one_dir_name = "私はガラスを食べられますlevel_one";
21$level_one_dir_path = "$base_dir_path/$level_one_dir_name";
22
23$level_two_dir_name = "私はガラスを食べられますlevel_two";
24$level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name";
25
26// create directories
27mkdir($level_one_dir_path);
28mkdir($level_two_dir_path);
29
30echo "\n-- \$path = './私はガラスを食べられますlevel_one': --\n";
31var_dump(chdir($base_dir_path));
32var_dump($dh = opendir("./$level_one_dir_name"));
33clean_dh($dh);
34
35echo "\n-- \$path = '私はガラスを食べられますlevel_one/私はガラスを食べられますlevel_two': --\n";
36var_dump(chdir($base_dir_path));
37var_dump($dh = opendir("$level_one_dir_name/$level_two_dir_name"));
38clean_dh($dh);
39
40echo "\n-- \$path = '..': --\n";
41var_dump($dh = opendir('..'));
42clean_dh($dh);
43
44echo "\n-- \$path = 'level_two', '.': --\n";
45var_dump(chdir($level_two_dir_path));
46var_dump($dh = opendir('.'));
47clean_dh($dh);
48
49echo "\n-- \$path = '../': --\n";
50var_dump($dh = opendir('../'));
51clean_dh($dh);
52
53echo "\n-- \$path = './': --\n";
54var_dump(chdir($level_two_dir_path));
55var_dump($dh = opendir('./'));
56clean_dh($dh);
57
58echo "\n-- \$path = '../../'私はガラスを食べられますlevel_one': --\n";
59var_dump(chdir($level_two_dir_path));
60var_dump($dh = opendir("../../$level_one_dir_name"));
61clean_dh($dh);
62
63/*
64 * function to remove directory handle before re-using variable name in test
65 * and to ensure directory is not in use at CLEAN section so can me removed
66 */
67function clean_dh($dh){
68    if (is_resource($dh)) {
69        closedir($dh);
70    }
71    unset($dh);
72}
73?>
74--CLEAN--
75<?php
76$base_dir_path = __DIR__ . '/opendir_variation4-win32-mb';
77rmdir("$base_dir_path/私はガラスを食べられますlevel_one/私はガラスを食べられますlevel_two");
78rmdir("$base_dir_path/私はガラスを食べられますlevel_one");
79rmdir($base_dir_path);
80?>
81--EXPECTF--
82*** Testing opendir() : usage variation ***
83
84-- $path = './私はガラスを食べられますlevel_one': --
85bool(true)
86resource(%d) of type (stream)
87
88-- $path = '私はガラスを食べられますlevel_one/私はガラスを食べられますlevel_two': --
89bool(true)
90resource(%d) of type (stream)
91
92-- $path = '..': --
93resource(%d) of type (stream)
94
95-- $path = 'level_two', '.': --
96bool(true)
97resource(%d) of type (stream)
98
99-- $path = '../': --
100resource(%d) of type (stream)
101
102-- $path = './': --
103bool(true)
104resource(%d) of type (stream)
105
106-- $path = '../../'私はガラスを食べられますlevel_one': --
107bool(true)
108resource(%d) of type (stream)
109