1--TEST--
2Test chdir() function : usage variations - relative paths
3--FILE--
4<?php
5/*
6 * Test chdir() with variations of relative paths
7 */
8
9echo "*** Testing chdir() : usage variations ***\n";
10
11$base_dir_path = __DIR__;
12
13$level2_one_dir_name = "level2_one";
14$level2_one_dir_path = "$base_dir_path/$level2_one_dir_name";
15
16$level2_two_dir_name = "level2_two";
17$level2_two_dir_path = "$base_dir_path/$level2_one_dir_name/$level2_two_dir_name";
18
19// create directories
20mkdir($level2_one_dir_path);
21mkdir($level2_two_dir_path);
22
23echo "\n-- \$directory = './level2_one': --\n";
24var_dump(chdir($base_dir_path));
25var_dump(chdir("./$level2_one_dir_name"));
26var_dump(getcwd());
27
28echo "\n-- \$directory = 'level2_one/level2_two': --\n";
29var_dump(chdir($base_dir_path));
30var_dump(chdir("$level2_one_dir_name/$level2_two_dir_name"));
31var_dump(getcwd());
32
33echo "\n-- \$directory = '..': --\n";
34var_dump(chdir('..'));
35var_dump(getcwd());
36
37echo "\n-- \$directory = 'level2_two', '.': --\n";
38var_dump(chdir($level2_two_dir_path));
39var_dump(chdir('.'));
40var_dump(getcwd());
41
42echo "\n-- \$directory = '../': --\n";
43var_dump(chdir('../'));
44var_dump(getcwd());
45
46echo "\n-- \$directory = './': --\n";
47var_dump(chdir($level2_two_dir_path));
48var_dump(chdir('./'));
49var_dump(getcwd());
50
51echo "\n-- \$directory = '../../'level2_one': --\n";
52var_dump(chdir($level2_two_dir_path));
53var_dump(chdir("../../$level2_one_dir_name"));
54var_dump(getcwd());
55
56?>
57--CLEAN--
58<?php
59$file_path = __DIR__;
60rmdir("$file_path/level2_one/level2_two");
61rmdir("$file_path/level2_one");
62?>
63--EXPECTF--
64*** Testing chdir() : usage variations ***
65
66-- $directory = './level2_one': --
67bool(true)
68bool(true)
69string(%d) "%slevel2_one"
70
71-- $directory = 'level2_one/level2_two': --
72bool(true)
73bool(true)
74string(%d) "%slevel2_one%elevel2_two"
75
76-- $directory = '..': --
77bool(true)
78string(%d) "%slevel2_one"
79
80-- $directory = 'level2_two', '.': --
81bool(true)
82bool(true)
83string(%d) "%slevel2_one%elevel2_two"
84
85-- $directory = '../': --
86bool(true)
87string(%d) "%slevel2_one"
88
89-- $directory = './': --
90bool(true)
91bool(true)
92string(%d) "%slevel2_one%elevel2_two"
93
94-- $directory = '../../'level2_one': --
95bool(true)
96bool(true)
97string(%d) "%slevel2_one"
98