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 only 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  if( file_exists($dest_file_name) ) {
51    echo "Destination file name => ";
52    print($dest_file_name);
53    echo "\n";
54
55    echo "Size of source file => ";
56    var_dump( filesize($src_file_name) );
57    clearstatcache();
58
59    echo "Size of destination file => ";
60    var_dump( filesize($dest_file_name) );
61    clearstatcache();
62
63    unlink($dest_file_name);
64  }
65  $count++;
66}
67
68echo "*** Done ***\n";
69?>
70--CLEAN--
71<?php
72unlink(__DIR__."/copy_variation3.tmp");
73?>
74--EXPECTF--
75*** Test copy() function: destination file names containing whitespaces ***
76Size of the source file before copy operation => int(1500)
77
78-- Now applying copy() on source file to create copies --
79-- Iteration 1 --
80Copy operation => bool(true)
81Existence of destination file => bool(true)
82Destination file name => copy variation3.tmp
83Size of source file => int(1500)
84Size of destination file => int(1500)
85
86-- Iteration 2 --
87Copy operation => bool(true)
88Existence of destination file => bool(true)
89Destination file name =>  copy_variation3.tmp
90Size of source file => int(1500)
91Size of destination file => int(1500)
92
93-- Iteration 3 --
94Copy operation =>
95Warning: copy(%s): %s
96bool(false)
97Existence of destination file => bool(false)
98
99-- Iteration 4 --
100Copy operation =>
101Warning: copy(%s): %s
102bool(false)
103Existence of destination file => bool(false)
104*** Done ***
105