1--TEST--
2Test opendir() function : basic functionality
3--FILE--
4<?php
5/*
6 * Test basic functionality of opendir() with absolute and relative paths as $path argument
7 */
8
9echo "*** Testing opendir() : basic functionality ***\n";
10
11$base_dir_path = __DIR__ . '/opendir_basic';
12@mkdir($base_dir_path);
13
14$level_one_dir_name = "level_one";
15$level_one_dir_path = "$base_dir_path/$level_one_dir_name";
16
17$level_two_dir_name = "level_two";
18$level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name";
19
20// create temporary directories - will remove in CLEAN section
21mkdir($level_one_dir_path);
22mkdir($level_two_dir_path);
23
24echo "\n-- Testing opendir() with absolute path: --\n";
25var_dump($dh1 = opendir($level_one_dir_path));
26
27
28echo "\n-- Testing opendir() with relative paths: --\n";
29var_dump(chdir($level_one_dir_path));
30var_dump($dh2 = opendir($level_two_dir_name));
31
32echo "\n-- Close directory handles: --\n";
33closedir($dh1);
34var_dump($dh1);
35closedir($dh2);
36var_dump($dh2);
37?>
38--CLEAN--
39<?php
40$base_dir_path = __DIR__ . '/opendir_basic';
41rmdir("$base_dir_path/level_one/level_two");
42rmdir("$base_dir_path/level_one");
43rmdir($base_dir_path);
44?>
45--EXPECTF--
46*** Testing opendir() : basic functionality ***
47
48-- Testing opendir() with absolute path: --
49resource(%d) of type (stream)
50
51-- Testing opendir() with relative paths: --
52bool(true)
53resource(%d) of type (stream)
54
55-- Close directory handles: --
56resource(%d) of type (Unknown)
57resource(%d) of type (Unknown)
58