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