1--TEST-- 2Test scandir() function : usage variations - different relative paths 3--FILE-- 4<?php 5/* 6 * Test scandir() with relative paths as $dir argument 7 */ 8 9echo "*** Testing scandir() : usage variations ***\n"; 10 11// include for create_files/delete_files functions 12include (__DIR__ . '/../file/file.inc'); 13 14$base_dir_path = __DIR__ . '/scandir_variation4'; 15@mkdir($base_dir_path); 16 17$level_one_dir_path = "$base_dir_path/level_one"; 18$level_two_dir_path = "$level_one_dir_path/level_two"; 19 20// create directories and files 21mkdir($level_one_dir_path); 22create_files($level_one_dir_path, 2, 'numeric', 0755, 1, 'w', 'level_one', 1); 23mkdir($level_two_dir_path); 24create_files($level_two_dir_path, 2, 'numeric', 0755, 1, 'w', 'level_two', 1); 25 26echo "\n-- \$path = './level_one': --\n"; 27var_dump(chdir($base_dir_path)); 28var_dump(scandir('./level_one')); 29 30echo "\n-- \$path = 'level_one/level_two': --\n"; 31var_dump(chdir($base_dir_path)); 32var_dump(scandir('level_one/level_two')); 33 34echo "\n-- \$path = '..': --\n"; 35var_dump(chdir($level_two_dir_path)); 36var_dump(scandir('..')); 37 38echo "\n-- \$path = 'level_two', '.': --\n"; 39var_dump(chdir($level_two_dir_path)); 40var_dump(scandir('.')); 41 42echo "\n-- \$path = '../': --\n"; 43var_dump(chdir($level_two_dir_path)); 44var_dump(scandir('../')); 45 46echo "\n-- \$path = './': --\n"; 47var_dump(chdir($level_two_dir_path)); 48var_dump(scandir('./')); 49 50echo "\n-- \$path = '../../'level_one': --\n"; 51var_dump(chdir($level_two_dir_path)); 52var_dump(scandir('../../level_one')); 53 54@delete_files($level_one_dir_path, 2, 'level_one'); 55@delete_files($level_two_dir_path, 2, 'level_two'); 56?> 57--CLEAN-- 58<?php 59$base_dir_path = __DIR__ . '/scandir_variation4'; 60rmdir("$base_dir_path/level_one/level_two"); 61rmdir("$base_dir_path/level_one"); 62rmdir($base_dir_path); 63?> 64--EXPECT-- 65*** Testing scandir() : usage variations *** 66 67-- $path = './level_one': -- 68bool(true) 69array(5) { 70 [0]=> 71 string(1) "." 72 [1]=> 73 string(2) ".." 74 [2]=> 75 string(14) "level_one1.tmp" 76 [3]=> 77 string(14) "level_one2.tmp" 78 [4]=> 79 string(9) "level_two" 80} 81 82-- $path = 'level_one/level_two': -- 83bool(true) 84array(4) { 85 [0]=> 86 string(1) "." 87 [1]=> 88 string(2) ".." 89 [2]=> 90 string(14) "level_two1.tmp" 91 [3]=> 92 string(14) "level_two2.tmp" 93} 94 95-- $path = '..': -- 96bool(true) 97array(5) { 98 [0]=> 99 string(1) "." 100 [1]=> 101 string(2) ".." 102 [2]=> 103 string(14) "level_one1.tmp" 104 [3]=> 105 string(14) "level_one2.tmp" 106 [4]=> 107 string(9) "level_two" 108} 109 110-- $path = 'level_two', '.': -- 111bool(true) 112array(4) { 113 [0]=> 114 string(1) "." 115 [1]=> 116 string(2) ".." 117 [2]=> 118 string(14) "level_two1.tmp" 119 [3]=> 120 string(14) "level_two2.tmp" 121} 122 123-- $path = '../': -- 124bool(true) 125array(5) { 126 [0]=> 127 string(1) "." 128 [1]=> 129 string(2) ".." 130 [2]=> 131 string(14) "level_one1.tmp" 132 [3]=> 133 string(14) "level_one2.tmp" 134 [4]=> 135 string(9) "level_two" 136} 137 138-- $path = './': -- 139bool(true) 140array(4) { 141 [0]=> 142 string(1) "." 143 [1]=> 144 string(2) ".." 145 [2]=> 146 string(14) "level_two1.tmp" 147 [3]=> 148 string(14) "level_two2.tmp" 149} 150 151-- $path = '../../'level_one': -- 152bool(true) 153array(5) { 154 [0]=> 155 string(1) "." 156 [1]=> 157 string(2) ".." 158 [2]=> 159 string(14) "level_one1.tmp" 160 [3]=> 161 string(14) "level_one2.tmp" 162 [4]=> 163 string(9) "level_two" 164} 165