1--TEST-- 2Test copy() function: usage variations - destination file names(white spaces) 3--SKIPIF-- 4<?php 5if(substr(PHP_OS, 0, 3) == "WIN") 6 die("skip do not run on Windows"); 7?> 8--CONFLICTS-- 9obscure_filename 10--FILE-- 11<?php 12/* Test copy() function: In creation of destination file names containing white spaces 13 and checking the existence and size of destination files 14*/ 15 16echo "*** Test copy() function: destination file names containing whitespaces ***\n"; 17$file_path = __DIR__; 18$src_file_name = $file_path."/copy_variation3.tmp"; 19$file_handle = fopen($src_file_name, "w"); 20fwrite( $file_handle, str_repeat("Hello2World...\n", 100) ); 21fclose($file_handle); 22 23/* array of destination file names */ 24$dest_files = array( 25 26 /* File names containing whitespaces */ 27 "copy variation3.tmp", //file name containing blank space 28 " copy_variation3.tmp", //file name starts with blank space 29 "copy\tvariation3.tmp", 30 " ", //blank space as file name 31); 32 33echo "Size of the source file before copy operation => "; 34var_dump( filesize("$src_file_name") ); 35clearstatcache(); 36 37echo "\n-- Now applying copy() on source file to create copies --"; 38$count = 1; 39foreach($dest_files as $dest_file) { 40 41 echo "\n-- Iteration $count --\n"; 42 $dest_file_name = $dest_file; 43 44 echo "Copy operation => "; 45 var_dump( copy($src_file_name, $dest_file_name) ); 46 47 echo "Existence of destination file => "; 48 var_dump( file_exists($dest_file_name) ); 49 50 echo "Destination file name => "; 51 print($dest_file_name); 52 echo "\n"; 53 54 echo "Size of source file => "; 55 var_dump( filesize($src_file_name) ); 56 clearstatcache(); 57 58 echo "Size of destination file => "; 59 var_dump( filesize($dest_file_name) ); 60 clearstatcache(); 61 62 unlink($dest_file_name); 63 64 $count++; 65} 66 67echo "*** Done ***\n"; 68?> 69--CLEAN-- 70<?php 71unlink(__DIR__."/copy_variation3.tmp"); 72?> 73--EXPECT-- 74*** Test copy() function: destination file names containing whitespaces *** 75Size of the source file before copy operation => int(1500) 76 77-- Now applying copy() on source file to create copies -- 78-- Iteration 1 -- 79Copy operation => bool(true) 80Existence of destination file => bool(true) 81Destination file name => copy variation3.tmp 82Size of source file => int(1500) 83Size of destination file => int(1500) 84 85-- Iteration 2 -- 86Copy operation => bool(true) 87Existence of destination file => bool(true) 88Destination file name => copy_variation3.tmp 89Size of source file => int(1500) 90Size of destination file => int(1500) 91 92-- Iteration 3 -- 93Copy operation => bool(true) 94Existence of destination file => bool(true) 95Destination file name => copy variation3.tmp 96Size of source file => int(1500) 97Size of destination file => int(1500) 98 99-- Iteration 4 -- 100Copy operation => bool(true) 101Existence of destination file => bool(true) 102Destination file name => 103Size of source file => int(1500) 104Size of destination file => int(1500) 105*** Done *** 106