Return to file_variation8-win32.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test file() function : variation - various absolute and relative 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 run on Windows"); 9: ?> 10: --FILE-- 11: <?php 12: /* Prototype : array file(string filename [, int flags[, resource context]]) 13: * Description: Read entire file into an array 14: * Source code: ext/standard/file.c 15: * Alias to functions: 16: */ 17: 18: echo "*** Testing file() : variation ***\n"; 19: $mainDir = "fileVar8.dir"; 20: $subDir = "fileVar8Sub"; 21: $absMainDir = dirname(__FILE__)."\\".$mainDir; 22: mkdir($absMainDir); 23: $absSubDir = $absMainDir."\\".$subDir; 24: mkdir($absSubDir); 25: 26: $old_dir_path = getcwd(); 27: chdir(dirname(__FILE__)); 28: $unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3); 29: 30: $allDirs = array( 31: // absolute paths 32: "$absSubDir\\", 33: "$absSubDir\\..\\".$subDir, 34: "$absSubDir\\\\..\\.\\".$subDir, 35: "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir, 36: "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir, 37: "$absSubDir\\BADDIR", 38: 39: // relative paths 40: $mainDir."\\".$subDir, 41: $mainDir."\\\\".$subDir, 42: $mainDir."\\\\\\".$subDir, 43: ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir, 44: "BADDIR", 45: 46: // unixifed path 47: $unixifiedDir, 48: ); 49: 50: $filename = 'FileGetContentsVar7.tmp'; 51: $absFile = $absSubDir.'/'.$filename; 52: $h = fopen($absFile,"w"); 53: fwrite($h, "contents read"); 54: fclose($h); 55: 56: for($i = 0; $i<count($allDirs); $i++) { 57: $j = $i+1; 58: $dir = $allDirs[$i]; 59: echo "\n-- Iteration $j --\n"; 60: var_dump(file($dir."\\".$filename)); 61: } 62: 63: unlink($absFile); 64: chdir($old_dir_path); 65: rmdir($absSubDir); 66: rmdir($absMainDir); 67: 68: echo "\n*** Done ***\n"; 69: ?> 70: --EXPECTF-- 71: *** Testing file() : variation *** 72: 73: -- Iteration 1 -- 74: array(1) { 75: [0]=> 76: string(13) "contents read" 77: } 78: 79: -- Iteration 2 -- 80: array(1) { 81: [0]=> 82: string(13) "contents read" 83: } 84: 85: -- Iteration 3 -- 86: array(1) { 87: [0]=> 88: string(13) "contents read" 89: } 90: 91: -- Iteration 4 -- 92: array(1) { 93: [0]=> 94: string(13) "contents read" 95: } 96: 97: -- Iteration 5 -- 98: 99: Warning: file(%sfileVar8.dir\fileVar8Sub\..\\\fileVar8Sub\\..\\..\fileVar8Sub\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d 100: bool(false) 101: 102: -- Iteration 6 -- 103: 104: Warning: file(%sfileVar8.dir\fileVar8Sub\BADDIR\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d 105: bool(false) 106: 107: -- Iteration 7 -- 108: array(1) { 109: [0]=> 110: string(13) "contents read" 111: } 112: 113: -- Iteration 8 -- 114: array(1) { 115: [0]=> 116: string(13) "contents read" 117: } 118: 119: -- Iteration 9 -- 120: array(1) { 121: [0]=> 122: string(13) "contents read" 123: } 124: 125: -- Iteration 10 -- 126: array(1) { 127: [0]=> 128: string(13) "contents read" 129: } 130: 131: -- Iteration 11 -- 132: 133: Warning: file(BADDIR\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d 134: bool(false) 135: 136: -- Iteration 12 -- 137: array(1) { 138: [0]=> 139: string(13) "contents read" 140: } 141: 142: *** Done ***