Return to opendir_basic.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / dir |
1.1 misho 1: --TEST-- 2: Test opendir() function : basic functionality 3: --FILE-- 4: <?php 5: /* Prototype : mixed opendir(string $path[, resource $context]) 6: * Description: Open a directory and return a dir_handle 7: * Source code: ext/standard/dir.c 8: */ 9: 10: /* 11: * Test basic functionality of opendir() with absolute and relative paths as $path argument 12: */ 13: 14: echo "*** Testing opendir() : basic functionality ***\n"; 15: 16: $base_dir_path = dirname(__FILE__); 17: 18: $level_one_dir_name = "level_one"; 19: $level_one_dir_path = "$base_dir_path/$level_one_dir_name"; 20: 21: $level_two_dir_name = "level_two"; 22: $level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name"; 23: 24: // create temporary directories - will remove in CLEAN section 25: mkdir($level_one_dir_path); 26: mkdir($level_two_dir_path); 27: 28: echo "\n-- Testing opendir() with absolute path: --\n"; 29: var_dump($dh1 = opendir($level_one_dir_path)); 30: 31: 32: echo "\n-- Testing opendir() with relative paths: --\n"; 33: var_dump(chdir($level_one_dir_path)); 34: var_dump($dh2 = opendir($level_two_dir_name)); 35: 36: echo "\n-- Close directory handles: --\n"; 37: closedir($dh1); 38: var_dump($dh1); 39: closedir($dh2); 40: var_dump($dh2); 41: ?> 42: ===DONE=== 43: --CLEAN-- 44: <?php 45: $file_path = dirname(__FILE__); 46: rmdir("$file_path/level_one/level_two"); 47: rmdir("$file_path/level_one"); 48: ?> 49: --EXPECTF-- 50: *** Testing opendir() : basic functionality *** 51: 52: -- Testing opendir() with absolute path: -- 53: resource(%d) of type (stream) 54: 55: -- Testing opendir() with relative paths: -- 56: bool(true) 57: resource(%d) of type (stream) 58: 59: -- Close directory handles: -- 60: resource(%d) of type (Unknown) 61: resource(%d) of type (Unknown) 62: ===DONE===