Return to realpath_basic-win32.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test realpath() function: basic functionality 3: --SKIPIF-- 4: <?php 5: if (substr(PHP_OS, 0, 3) != 'WIN') { 6: die('skip only on Windows'); 7: } 8: ?> 9: --FILE-- 10: <?php 11: /* Prototype: string realpath ( string $path ); 12: Description: Returns canonicalized absolute pathname 13: */ 14: 15: echo "\n*** Testing basic functions of realpath() with files ***\n"; 16: 17: /* creating directories and files */ 18: $file_path = dirname(__FILE__); 19: mkdir("$file_path/realpath_basic/home/test/", 0777, true); 20: 21: $file_handle1 = fopen("$file_path/realpath_basic/home/test/realpath_basic.tmp", "w"); 22: $file_handle2 = fopen("$file_path/realpath_basic/home/realpath_basic.tmp", "w"); 23: $file_handle3 = fopen("$file_path/realpath_basic/realpath_basic.tmp", "w"); 24: fclose($file_handle1); 25: fclose($file_handle2); 26: fclose($file_handle3); 27: 28: echo "\n*** Testing realpath() on filenames ***\n"; 29: $filenames = array ( 30: /* filenames resulting in valid paths */ 31: "$file_path/realpath_basic/home/realpath_basic.tmp", 32: "$file_path/realpath_basic/realpath_basic.tmp/", 33: "$file_path/realpath_basic//home/test//../test/./realpath_basic.tmp", 34: "$file_path/realpath_basic/home//../././realpath_basic.tmp//", 35: 36: // checking for binary safe 37: b"$file_path/realpath_basic/home/realpath_basic.tmp", 38: 39: /* filenames with invalid path */ 40: "$file_path///realpath_basic/home//..//././test//realpath_basic.tmp", 41: "$file_path/realpath_basic/home/../home/../test/../..realpath_basic.tmp" 42: ); 43: 44: $counter = 1; 45: /* loop through $files to read the filepath of $file in the above array */ 46: foreach($filenames as $file) { 47: echo "\n-- Iteration $counter --\n"; 48: var_dump( realpath($file) ); 49: $counter++; 50: } 51: 52: echo "Done\n"; 53: ?> 54: --CLEAN-- 55: <?php 56: $name_prefix = dirname(__FILE__)."/realpath_basic"; 57: unlink("$name_prefix/home/test/realpath_basic.tmp"); 58: unlink("$name_prefix/home/realpath_basic.tmp"); 59: unlink("$name_prefix/realpath_basic.tmp"); 60: rmdir("$name_prefix/home/test/"); 61: rmdir("$name_prefix/home/"); 62: rmdir("$name_prefix/"); 63: ?> 64: --EXPECTF-- 65: *** Testing basic functions of realpath() with files *** 66: 67: *** Testing realpath() on filenames *** 68: 69: -- Iteration 1 -- 70: string(%d) "%s\realpath_basic\home\realpath_basic.tmp" 71: 72: -- Iteration 2 -- 73: bool(false) 74: 75: -- Iteration 3 -- 76: string(%d) "%s\realpath_basic\home\test\realpath_basic.tmp" 77: 78: -- Iteration 4 -- 79: bool(false) 80: 81: -- Iteration 5 -- 82: string(%d) "%s\realpath_basic\home\realpath_basic.tmp" 83: 84: -- Iteration 6 -- 85: bool(false) 86: 87: -- Iteration 7 -- 88: bool(false) 89: Done