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 only 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  ":copy_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);
44
45echo "Size of the source file before copy operation => ";
46var_dump( filesize("$src_file_name") );
47clearstatcache();
48
49echo "\n--- Now applying copy() on source file to create copies ---";
50$count = 1;
51foreach($dest_files as $dest_file) {
52  echo "\n-- Iteration $count --\n";
53  $dest_file_name = $file_path."/$dest_file";
54
55  echo "Copy operation => ";
56  var_dump( copy($src_file_name, $dest_file_name) );
57
58  echo "Existence of destination file => ";
59  var_dump( file_exists($dest_file_name) );
60
61  if( file_exists($dest_file_name) ) {
62    echo "Destination file name => ";
63    print($dest_file_name);
64    echo "\n";
65
66    echo "Size of source file => ";
67    var_dump( filesize($src_file_name) );
68    clearstatcache();
69
70    echo "Size of destination file => ";
71    var_dump( filesize($dest_file_name) );
72    clearstatcache();
73
74    unlink($dest_file_name);
75  }
76  $count++;
77}
78
79echo "*** Done ***\n";
80?>
81--CLEAN--
82<?php
83unlink(__DIR__."/copy_variation2私はガラスを食べられます.tmp");
84?>
85--EXPECTF--
86*** Test copy() function: destination file names containing special characters ***
87Size of the source file before copy operation => int(1500)
88
89--- Now applying copy() on source file to create copies ---
90-- Iteration 1 --
91Copy operation => bool(true)
92Existence of destination file => bool(true)
93Destination file name => %s/_copy_variation2.tmp
94Size of source file => int(1500)
95Size of destination file => int(1500)
96
97-- Iteration 2 --
98Copy operation => bool(true)
99Existence of destination file => bool(true)
100Destination file name => %s/@copy_variation2.tmp
101Size of source file => int(1500)
102Size of destination file => int(1500)
103
104-- Iteration 3 --
105Copy operation => bool(true)
106Existence of destination file => bool(true)
107Destination file name => %s/#copy_variation2.tmp
108Size of source file => int(1500)
109Size of destination file => int(1500)
110
111-- Iteration 4 --
112Copy operation => bool(true)
113Existence of destination file => bool(true)
114Destination file name => %s/+copy_variation2.tmp
115Size of source file => int(1500)
116Size of destination file => int(1500)
117
118-- Iteration 5 --
119Copy operation =>
120Warning: copy(%s): %s
121bool(false)
122Existence of destination file => bool(false)
123
124-- Iteration 6 --
125Copy operation =>
126Warning: copy(%s): %s
127bool(false)
128Existence of destination file => bool(false)
129
130-- Iteration 7 --
131Copy operation => bool(true)
132Existence of destination file => bool(true)
133Destination file name => %s/!copy_variation2.tmp
134Size of source file => int(1500)
135Size of destination file => int(1500)
136
137-- Iteration 8 --
138Copy operation => bool(true)
139Existence of destination file => bool(true)
140Destination file name => %s/&copy_variation2.tmp
141Size of source file => int(1500)
142Size of destination file => int(1500)
143
144-- Iteration 9 --
145Copy operation => bool(true)
146Existence of destination file => bool(true)
147Destination file name => %s/(copy_variation2.tmp
148Size of source file => int(1500)
149Size of destination file => int(1500)
150
151-- Iteration 10 --
152Copy operation =>
153Warning: copy(%s): %s
154bool(false)
155Existence of destination file => bool(false)
156
157-- Iteration 11 --
158Copy operation => bool(true)
159Existence of destination file => bool(true)
160Destination file name => %s/;copy_variation2.tmp
161Size of source file => int(1500)
162Size of destination file => int(1500)
163
164-- Iteration 12 --
165Copy operation => bool(true)
166Existence of destination file => bool(true)
167Destination file name => %s/=copy_variation2.tmp
168Size of source file => int(1500)
169Size of destination file => int(1500)
170
171-- Iteration 13 --
172Copy operation => bool(true)
173Existence of destination file => bool(true)
174Destination file name => %s/[copy_variation2.tmp
175Size of source file => int(1500)
176Size of destination file => int(1500)
177
178-- Iteration 14 --
179Copy operation => bool(true)
180Existence of destination file => bool(true)
181Destination file name => %s/^copy_variation2.tmp
182Size of source file => int(1500)
183Size of destination file => int(1500)
184
185-- Iteration 15 --
186Copy operation => bool(true)
187Existence of destination file => bool(true)
188Destination file name => %s/{copy_variation2.tmp
189Size of source file => int(1500)
190Size of destination file => int(1500)
191
192-- Iteration 16 --
193Copy operation =>
194Warning: copy(%s): %s
195bool(false)
196Existence of destination file => bool(false)
197
198-- Iteration 17 --
199Copy operation => bool(true)
200Existence of destination file => bool(true)
201Destination file name => %s/~copy_variation2.tmp
202Size of source file => int(1500)
203Size of destination file => int(1500)
204
205-- Iteration 18 --
206Copy operation => bool(true)
207Existence of destination file => bool(true)
208Destination file name => %s/$copy_variation2.tmp
209Size of source file => int(1500)
210Size of destination file => int(1500)
211*** Done ***
212