Return to file_get_contents_variation7-win32.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test file_get_contents() 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 : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]]) 13: * Description: Read the entire file into a string 14: * Source code: ext/standard/file.c 15: * Alias to functions: 16: */ 17: 18: echo "*** Testing file_get_contents() : variation ***\n"; 19: $mainDir = "fileGetContentsVar7.dir"; 20: $subDir = "fileGetContentsVar7Sub"; 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_get_contents($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_get_contents() : variation *** 72: 73: -- Iteration 1 -- 74: string(%d) "contents read" 75: 76: -- Iteration 2 -- 77: string(%d) "contents read" 78: 79: -- Iteration 3 -- 80: string(%d) "contents read" 81: 82: -- Iteration 4 -- 83: string(%d) "contents read" 84: 85: -- Iteration 5 -- 86: 87: Warning: file_get_contents(%sfileGetContentsVar7.dir\fileGetContentsVar7Sub\..\\\fileGetContentsVar7Sub\\..\\..\fileGetContentsVar7Sub\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d 88: bool(false) 89: 90: -- Iteration 6 -- 91: 92: Warning: file_get_contents(%sfileGetContentsVar7.dir\fileGetContentsVar7Sub\BADDIR\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d 93: bool(false) 94: 95: -- Iteration 7 -- 96: string(%d) "contents read" 97: 98: -- Iteration 8 -- 99: string(%d) "contents read" 100: 101: -- Iteration 9 -- 102: string(%d) "contents read" 103: 104: -- Iteration 10 -- 105: string(%d) "contents read" 106: 107: -- Iteration 11 -- 108: 109: Warning: file_get_contents(BADDIR\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d 110: bool(false) 111: 112: -- Iteration 12 -- 113: string(%d) "contents read" 114: 115: *** Done ***