Return to copy_variation2-win32.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test copy() function: usage variations - destination file names(special chars) 3: --SKIPIF-- 4: <?php 5: if(substr(PHP_OS, 0, 3) != "WIN") 6: die("skip only run on Windows"); 7: ?> 8: --FILE-- 9: <?php 10: /* Prototype: bool copy ( string $source, string $dest ); 11: Description: Makes a copy of the file source to dest. 12: Returns TRUE on success or FALSE on failure. 13: */ 14: 15: /* Test copy() function: In creation of destination file names containing special characters 16: and checking the existence and size of destination files 17: */ 18: 19: echo "*** Test copy() function: destination file names containing special characters ***\n"; 20: $file_path = dirname(__FILE__); 21: $src_file_name = $file_path."/copy_variation2.tmp"; 22: $file_handle = fopen($src_file_name, "w"); 23: fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) ); 24: fclose($file_handle); 25: 26: /* array of destination file names */ 27: $dest_files = array( 28: 29: /* File names containing special(non-alpha numeric) characters */ 30: "_copy_variation2.tmp", 31: "@copy_variation2.tmp", 32: "#copy_variation2.tmp", 33: "+copy_variation2.tmp", 34: "?copy_variation2.tmp", 35: ">copy_variation2.tmp", 36: "!copy_variation2.tmp", 37: "©_variation2.tmp", 38: "(copy_variation2.tmp", 39: ":copy_variation2.tmp", 40: ";copy_variation2.tmp", 41: "=copy_variation2.tmp", 42: "[copy_variation2.tmp", 43: "^copy_variation2.tmp", 44: "{copy_variation2.tmp", 45: "|copy_variation2.tmp", 46: "~copy_variation2.tmp", 47: "\$copy_variation2.tmp" 48: ); 49: 50: echo "Size of the source file before copy operation => "; 51: var_dump( filesize("$src_file_name") ); 52: clearstatcache(); 53: 54: echo "\n--- Now applying copy() on source file to create copies ---"; 55: $count = 1; 56: foreach($dest_files as $dest_file) { 57: echo "\n-- Iteration $count --\n"; 58: $dest_file_name = $file_path."/$dest_file"; 59: 60: echo "Copy operation => "; 61: var_dump( copy($src_file_name, $dest_file_name) ); 62: 63: echo "Existence of destination file => "; 64: var_dump( file_exists($dest_file_name) ); 65: 66: if( file_exists($dest_file_name) ) { 67: echo "Destination file name => "; 68: print($dest_file_name); 69: echo "\n"; 70: 71: echo "Size of source file => "; 72: var_dump( filesize($src_file_name) ); 73: clearstatcache(); 74: 75: echo "Size of destination file => "; 76: var_dump( filesize($dest_file_name) ); 77: clearstatcache(); 78: 79: unlink($dest_file_name); 80: } 81: $count++; 82: } 83: 84: echo "*** Done ***\n"; 85: ?> 86: 87: --CLEAN-- 88: <?php 89: unlink(dirname(__FILE__)."/copy_variation2.tmp"); 90: ?> 91: 92: --EXPECTF-- 93: *** Test copy() function: destination file names containing special characters *** 94: Size of the source file before copy operation => int(1500) 95: 96: --- Now applying copy() on source file to create copies --- 97: -- Iteration 1 -- 98: Copy operation => bool(true) 99: Existence of destination file => bool(true) 100: Destination file name => %s/_copy_variation2.tmp 101: Size of source file => int(1500) 102: Size of destination file => int(1500) 103: 104: -- Iteration 2 -- 105: Copy operation => bool(true) 106: Existence of destination file => bool(true) 107: Destination file name => %s/@copy_variation2.tmp 108: Size of source file => int(1500) 109: Size of destination file => int(1500) 110: 111: -- Iteration 3 -- 112: Copy operation => bool(true) 113: Existence of destination file => bool(true) 114: Destination file name => %s/#copy_variation2.tmp 115: Size of source file => int(1500) 116: Size of destination file => int(1500) 117: 118: -- Iteration 4 -- 119: Copy operation => bool(true) 120: Existence of destination file => bool(true) 121: Destination file name => %s/+copy_variation2.tmp 122: Size of source file => int(1500) 123: Size of destination file => int(1500) 124: 125: -- Iteration 5 -- 126: Copy operation => 127: Warning: copy(%s): %s 128: bool(false) 129: Existence of destination file => bool(false) 130: 131: -- Iteration 6 -- 132: Copy operation => 133: Warning: copy(%s): %s 134: bool(false) 135: Existence of destination file => bool(false) 136: 137: -- Iteration 7 -- 138: Copy operation => bool(true) 139: Existence of destination file => bool(true) 140: Destination file name => %s/!copy_variation2.tmp 141: Size of source file => int(1500) 142: Size of destination file => int(1500) 143: 144: -- Iteration 8 -- 145: Copy operation => bool(true) 146: Existence of destination file => bool(true) 147: Destination file name => %s/©_variation2.tmp 148: Size of source file => int(1500) 149: Size of destination file => int(1500) 150: 151: -- Iteration 9 -- 152: Copy operation => bool(true) 153: Existence of destination file => bool(true) 154: Destination file name => %s/(copy_variation2.tmp 155: Size of source file => int(1500) 156: Size of destination file => int(1500) 157: 158: -- Iteration 10 -- 159: Copy operation => 160: Warning: copy(%s): %s 161: bool(false) 162: Existence of destination file => bool(false) 163: 164: -- Iteration 11 -- 165: Copy operation => bool(true) 166: Existence of destination file => bool(true) 167: Destination file name => %s/;copy_variation2.tmp 168: Size of source file => int(1500) 169: Size of destination file => int(1500) 170: 171: -- Iteration 12 -- 172: Copy operation => bool(true) 173: Existence of destination file => bool(true) 174: Destination file name => %s/=copy_variation2.tmp 175: Size of source file => int(1500) 176: Size of destination file => int(1500) 177: 178: -- Iteration 13 -- 179: Copy operation => bool(true) 180: Existence of destination file => bool(true) 181: Destination file name => %s/[copy_variation2.tmp 182: Size of source file => int(1500) 183: Size of destination file => int(1500) 184: 185: -- Iteration 14 -- 186: Copy operation => bool(true) 187: Existence of destination file => bool(true) 188: Destination file name => %s/^copy_variation2.tmp 189: Size of source file => int(1500) 190: Size of destination file => int(1500) 191: 192: -- Iteration 15 -- 193: Copy operation => bool(true) 194: Existence of destination file => bool(true) 195: Destination file name => %s/{copy_variation2.tmp 196: Size of source file => int(1500) 197: Size of destination file => int(1500) 198: 199: -- Iteration 16 -- 200: Copy operation => 201: Warning: copy(%s): %s 202: bool(false) 203: Existence of destination file => bool(false) 204: 205: -- Iteration 17 -- 206: Copy operation => bool(true) 207: Existence of destination file => bool(true) 208: Destination file name => %s/~copy_variation2.tmp 209: Size of source file => int(1500) 210: Size of destination file => int(1500) 211: 212: -- Iteration 18 -- 213: Copy operation => bool(true) 214: Existence of destination file => bool(true) 215: Destination file name => %s/$copy_variation2.tmp 216: Size of source file => int(1500) 217: Size of destination file => int(1500) 218: *** Done ***