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