Return to copy_variation1.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(numerics/strings) 3: --FILE-- 4: <?php 5: /* Prototype: bool copy ( string $source, string $dest ); 6: Description: Makes a copy of the file source to dest. 7: Returns TRUE on success or FALSE on failure. 8: */ 9: 10: /* Test copy() function: In creation of destination file names containing numerics/strings 11: and checking the existence and size of destination files 12: */ 13: 14: echo "*** Test copy() function: destination file names containing numerics/strings ***\n"; 15: $file_path = dirname(__FILE__); 16: $src_file_name = $file_path."/copy_variation1.tmp"; 17: $file_handle = fopen($src_file_name, "w"); 18: fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) ); 19: fclose($file_handle); 20: 21: /* array of destination file names */ 22: $dest_files = array( 23: 24: /* File names containing numerics, strings */ 25: "copy.tmp", //regular file name 26: "copy_copy_variation1.tmp", 27: ".tmp", //file name only with extension 28: "123.tmp", //file name starts with numeric and with regular extension 29: "copy_variation1.123", //file name with numeric extension 30: "123", //numeric 31: "123copy_variation1.tmp", //file name containing numeric & string 32: "copy_variation.tmp123", //file name containing string & numeric 33: chr(99).chr(111).chr(112).chr(121).chr(49).".tmp" //file name containing ASCII values 34: ); 35: 36: echo "Size of the source file before copy operation => "; 37: var_dump( filesize("$src_file_name") ); 38: clearstatcache(); 39: 40: echo "\n-- Now applying copy() on source file to create copies --"; 41: $count = 1; 42: foreach($dest_files as $dest_file) { 43: echo "\n-- Iteration $count --\n"; 44: 45: $dest_file_name = "$file_path/$dest_file"; 46: 47: echo "Copy operation => "; 48: var_dump( copy($src_file_name, $dest_file_name) ); 49: 50: echo "Existence of destination file => "; 51: var_dump( file_exists($dest_file_name) ); 52: 53: echo "Destination file name => "; 54: print($dest_file_name); 55: echo "\n"; 56: 57: echo "Size of source file => "; 58: var_dump( filesize($src_file_name) ); 59: clearstatcache(); 60: 61: echo "Size of destination file => "; 62: var_dump( filesize($dest_file_name) ); 63: clearstatcache(); 64: 65: unlink($dest_file_name); 66: 67: $count++; 68: } 69: 70: echo "*** Done ***\n"; 71: ?> 72: 73: --CLEAN-- 74: <?php 75: unlink(dirname(__FILE__)."/copy_variation1.tmp"); 76: ?> 77: 78: --EXPECTF-- 79: *** Test copy() function: destination file names containing numerics/strings *** 80: Size of the source file before copy operation => int(1500) 81: 82: -- Now applying copy() on source file to create copies -- 83: -- Iteration 1 -- 84: Copy operation => bool(true) 85: Existence of destination file => bool(true) 86: Destination file name => %s/copy.tmp 87: Size of source file => int(1500) 88: Size of destination file => int(1500) 89: 90: -- Iteration 2 -- 91: Copy operation => bool(true) 92: Existence of destination file => bool(true) 93: Destination file name => %s/copy_copy_variation1.tmp 94: Size of source file => int(1500) 95: Size of destination file => int(1500) 96: 97: -- Iteration 3 -- 98: Copy operation => bool(true) 99: Existence of destination file => bool(true) 100: Destination file name => %s/.tmp 101: Size of source file => int(1500) 102: Size of destination file => int(1500) 103: 104: -- Iteration 4 -- 105: Copy operation => bool(true) 106: Existence of destination file => bool(true) 107: Destination file name => %s/123.tmp 108: Size of source file => int(1500) 109: Size of destination file => int(1500) 110: 111: -- Iteration 5 -- 112: Copy operation => bool(true) 113: Existence of destination file => bool(true) 114: Destination file name => %s/copy_variation1.123 115: Size of source file => int(1500) 116: Size of destination file => int(1500) 117: 118: -- Iteration 6 -- 119: Copy operation => bool(true) 120: Existence of destination file => bool(true) 121: Destination file name => %s/123 122: Size of source file => int(1500) 123: Size of destination file => int(1500) 124: 125: -- Iteration 7 -- 126: Copy operation => bool(true) 127: Existence of destination file => bool(true) 128: Destination file name => %s/123copy_variation1.tmp 129: Size of source file => int(1500) 130: Size of destination file => int(1500) 131: 132: -- Iteration 8 -- 133: Copy operation => bool(true) 134: Existence of destination file => bool(true) 135: Destination file name => %s/copy_variation.tmp123 136: Size of source file => int(1500) 137: Size of destination file => int(1500) 138: 139: -- Iteration 9 -- 140: Copy operation => bool(true) 141: Existence of destination file => bool(true) 142: Destination file name => %s/copy1.tmp 143: Size of source file => int(1500) 144: Size of destination file => int(1500) 145: *** Done ***