Return to rename_variation11-win32.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test rename() function : variation - various relative, absolute paths 3: --CREDITS-- 4: Dave Kelsey <d_kelsey@uk.ibm.com> 5: --SKIPIF-- 6: <?php 7: if(substr(PHP_OS, 0, 3) != "WIN") 8: die("skip Only valid for Windows"); 9: ?> 10: --FILE-- 11: <?php 12: /* Prototype : bool rename(string old_name, string new_name[, resource context]) 13: * Description: Rename a file 14: * Source code: ext/standard/file.c 15: * Alias to functions: 16: */ 17: 18: echo "*** Testing rename() with absolute and relative paths ***\n"; 19: $mainDir = "renameVar11"; 20: $subDir = "renameVar11Sub"; 21: $absMainDir = dirname(__FILE__)."\\".$mainDir; 22: mkdir($absMainDir); 23: $absSubDir = $absMainDir."\\".$subDir; 24: mkdir($absSubDir); 25: 26: $fromFile = "renameMe.tmp"; 27: $toFile = "IwasRenamed.tmp"; 28: 29: $old_dir_path = getcwd(); 30: chdir(dirname(__FILE__)); 31: $unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3); 32: 33: 34: $allDirs = array( 35: // absolute paths 36: "$absSubDir\\", 37: "$absSubDir\\..\\".$subDir, 38: "$absSubDir\\\\..\\.\\".$subDir, 39: "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir, 40: "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir, 41: "$absSubDir\\BADDIR", 42: 43: // relative paths 44: $mainDir."\\".$subDir, 45: $mainDir."\\\\".$subDir, 46: $mainDir."\\\\\\".$subDir, 47: ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir, 48: "BADDIR", 49: 50: // unixifed path 51: $unixifiedDir, 52: ); 53: 54: for($i = 0; $i<count($allDirs); $i++) { 55: $j = $i+1; 56: $dir = $allDirs[$i]; 57: echo "\n-- Iteration $j --\n"; 58: touch($absSubDir."\\".$fromFile); 59: $res = rename($dir."\\".$fromFile, $dir."\\".$toFile); 60: var_dump($res); 61: if ($res == true) { 62: $res = rename($dir."\\".$toFile, $dir."\\".$fromFile); 63: var_dump($res); 64: } 65: unlink($absSubDir."\\".$fromFile); 66: } 67: 68: chdir($old_dir_path); 69: rmdir($absSubDir); 70: rmdir($absMainDir); 71: 72: echo "\n*** Done ***\n"; 73: ?> 74: --EXPECTF-- 75: *** Testing rename() with absolute and relative paths *** 76: 77: -- Iteration 1 -- 78: bool(true) 79: bool(true) 80: 81: -- Iteration 2 -- 82: bool(true) 83: bool(true) 84: 85: -- Iteration 3 -- 86: bool(true) 87: bool(true) 88: 89: -- Iteration 4 -- 90: bool(true) 91: bool(true) 92: 93: -- Iteration 5 -- 94: 95: Warning: rename(%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\renameMe.tmp,%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d 96: bool(false) 97: 98: -- Iteration 6 -- 99: 100: Warning: rename(%s\renameVar11\renameVar11Sub\BADDIR\renameMe.tmp,%s\renameVar11\renameVar11Sub\BADDIR\IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d 101: bool(false) 102: 103: -- Iteration 7 -- 104: bool(true) 105: bool(true) 106: 107: -- Iteration 8 -- 108: bool(true) 109: bool(true) 110: 111: -- Iteration 9 -- 112: bool(true) 113: bool(true) 114: 115: -- Iteration 10 -- 116: bool(true) 117: bool(true) 118: 119: -- Iteration 11 -- 120: 121: Warning: rename(BADDIR\renameMe.tmp,BADDIR\IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d 122: bool(false) 123: 124: -- Iteration 12 -- 125: bool(true) 126: bool(true) 127: 128: *** Done ***