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