Annotation of embedaddon/php/ext/standard/tests/file/copy_variation2.phpt, revision 1.1
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 do not 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: ">copy_variation2.tmp",
! 38: "!copy_variation2.tmp",
! 39: "©_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: "~copy_variation2.tmp",
! 49: "\$copy_variation2.tmp"
! 50: );
! 51:
! 52: echo "Size of the source file before copy operation => ";
! 53: var_dump( filesize("$src_file_name") );
! 54: clearstatcache();
! 55:
! 56: echo "\n--- Now applying copy() on source file to create copies ---";
! 57: $count = 1;
! 58: foreach($dest_files as $dest_file) {
! 59: echo "\n-- Iteration $count --\n";
! 60: $dest_file_name = $file_path."/$dest_file";
! 61:
! 62: echo "Copy operation => ";
! 63: var_dump( copy($src_file_name, $dest_file_name) );
! 64:
! 65: echo "Existence of destination file => ";
! 66: var_dump( file_exists($dest_file_name) );
! 67:
! 68: echo "Destination file name => ";
! 69: print($dest_file_name);
! 70: echo "\n";
! 71:
! 72: echo "Size of source file => ";
! 73: var_dump( filesize($src_file_name) );
! 74: clearstatcache();
! 75:
! 76: echo "Size of destination file => ";
! 77: var_dump( filesize($dest_file_name) );
! 78: clearstatcache();
! 79:
! 80: unlink($dest_file_name);
! 81:
! 82: $count++;
! 83: }
! 84:
! 85: echo "*** Done ***\n";
! 86: ?>
! 87:
! 88: --CLEAN--
! 89: <?php
! 90: unlink(dirname(__FILE__)."/copy_variation2.tmp");
! 91: ?>
! 92:
! 93: --EXPECTF--
! 94: *** Test copy() function: destination file names containing special characters ***
! 95: Size of the source file before copy operation => int(1500)
! 96:
! 97: --- Now applying copy() on source file to create copies ---
! 98: -- Iteration 1 --
! 99: Copy operation => bool(true)
! 100: Existence of destination file => bool(true)
! 101: Destination file name => %s/_copy_variation2.tmp
! 102: Size of source file => int(1500)
! 103: Size of destination file => int(1500)
! 104:
! 105: -- Iteration 2 --
! 106: Copy operation => bool(true)
! 107: Existence of destination file => bool(true)
! 108: Destination file name => %s/@copy_variation2.tmp
! 109: Size of source file => int(1500)
! 110: Size of destination file => int(1500)
! 111:
! 112: -- Iteration 3 --
! 113: Copy operation => bool(true)
! 114: Existence of destination file => bool(true)
! 115: Destination file name => %s/#copy_variation2.tmp
! 116: Size of source file => int(1500)
! 117: Size of destination file => int(1500)
! 118:
! 119: -- Iteration 4 --
! 120: Copy operation => bool(true)
! 121: Existence of destination file => bool(true)
! 122: Destination file name => %s/+copy_variation2.tmp
! 123: Size of source file => int(1500)
! 124: Size of destination file => int(1500)
! 125:
! 126: -- Iteration 5 --
! 127: Copy operation => bool(true)
! 128: Existence of destination file => bool(true)
! 129: Destination file name => %s/*copy_variation2.tmp
! 130: Size of source file => int(1500)
! 131: Size of destination file => int(1500)
! 132:
! 133: -- Iteration 6 --
! 134: Copy operation => bool(true)
! 135: Existence of destination file => bool(true)
! 136: Destination file name => %s/?copy_variation2.tmp
! 137: Size of source file => int(1500)
! 138: Size of destination file => int(1500)
! 139:
! 140: -- Iteration 7 --
! 141: Copy operation => bool(true)
! 142: Existence of destination file => bool(true)
! 143: Destination file name => %s/<copy_variation2.tmp
! 144: Size of source file => int(1500)
! 145: Size of destination file => int(1500)
! 146:
! 147: -- Iteration 8 --
! 148: Copy operation => bool(true)
! 149: Existence of destination file => bool(true)
! 150: Destination file name => %s/>copy_variation2.tmp
! 151: Size of source file => int(1500)
! 152: Size of destination file => int(1500)
! 153:
! 154: -- Iteration 9 --
! 155: Copy operation => bool(true)
! 156: Existence of destination file => bool(true)
! 157: Destination file name => %s/!copy_variation2.tmp
! 158: Size of source file => int(1500)
! 159: Size of destination file => int(1500)
! 160:
! 161: -- Iteration 10 --
! 162: Copy operation => bool(true)
! 163: Existence of destination file => bool(true)
! 164: Destination file name => %s/©_variation2.tmp
! 165: Size of source file => int(1500)
! 166: Size of destination file => int(1500)
! 167:
! 168: -- Iteration 11 --
! 169: Copy operation => bool(true)
! 170: Existence of destination file => bool(true)
! 171: Destination file name => %s/(copy_variation2.tmp
! 172: Size of source file => int(1500)
! 173: Size of destination file => int(1500)
! 174:
! 175: -- Iteration 12 --
! 176: Copy operation => bool(true)
! 177: Existence of destination file => bool(true)
! 178: Destination file name => %s/:copy_variation2.tmp
! 179: Size of source file => int(1500)
! 180: Size of destination file => int(1500)
! 181:
! 182: -- Iteration 13 --
! 183: Copy operation => bool(true)
! 184: Existence of destination file => bool(true)
! 185: Destination file name => %s/;copy_variation2.tmp
! 186: Size of source file => int(1500)
! 187: Size of destination file => int(1500)
! 188:
! 189: -- Iteration 14 --
! 190: Copy operation => bool(true)
! 191: Existence of destination file => bool(true)
! 192: Destination file name => %s/=copy_variation2.tmp
! 193: Size of source file => int(1500)
! 194: Size of destination file => int(1500)
! 195:
! 196: -- Iteration 15 --
! 197: Copy operation => bool(true)
! 198: Existence of destination file => bool(true)
! 199: Destination file name => %s/[copy_variation2.tmp
! 200: Size of source file => int(1500)
! 201: Size of destination file => int(1500)
! 202:
! 203: -- Iteration 16 --
! 204: Copy operation => bool(true)
! 205: Existence of destination file => bool(true)
! 206: Destination file name => %s/^copy_variation2.tmp
! 207: Size of source file => int(1500)
! 208: Size of destination file => int(1500)
! 209:
! 210: -- Iteration 17 --
! 211: Copy operation => bool(true)
! 212: Existence of destination file => bool(true)
! 213: Destination file name => %s/{copy_variation2.tmp
! 214: Size of source file => int(1500)
! 215: Size of destination file => int(1500)
! 216:
! 217: -- Iteration 18 --
! 218: Copy operation => bool(true)
! 219: Existence of destination file => bool(true)
! 220: Destination file name => %s/|copy_variation2.tmp
! 221: Size of source file => int(1500)
! 222: Size of destination file => int(1500)
! 223:
! 224: -- Iteration 19 --
! 225: Copy operation => bool(true)
! 226: Existence of destination file => bool(true)
! 227: Destination file name => %s/~copy_variation2.tmp
! 228: Size of source file => int(1500)
! 229: Size of destination file => int(1500)
! 230:
! 231: -- Iteration 20 --
! 232: Copy operation => bool(true)
! 233: Existence of destination file => bool(true)
! 234: Destination file name => %s/$copy_variation2.tmp
! 235: Size of source file => int(1500)
! 236: Size of destination file => int(1500)
! 237: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>