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/* Prototype: bool copy ( string $source, string $dest );
11   Description: Makes a copy of the file source to dest.
12     Returns TRUE on success or FALSE on failure.
13*/
14
15/* Test copy() function: In creation of destination file names containing special characters
16     and checking the existence and size of destination files
17*/
18
19echo "*** Test copy() function: destination file names containing special characters ***\n";
20$file_path = dirname(__FILE__);
21$src_file_name = $file_path."/copy_variation2.tmp";
22$file_handle = fopen($src_file_name, "w");
23fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) );
24fclose($file_handle);
25
26/* array of destination file names */
27$dest_files = array(
28
29  /* File names containing special(non-alpha numeric) characters */
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  "=copy_variation2.tmp",
44  "[copy_variation2.tmp",
45  "^copy_variation2.tmp",
46  "{copy_variation2.tmp",
47  "|copy_variation2.tmp",
48  "~copy_variation2.tmp",
49  "\$copy_variation2.tmp"
50);
51
52echo "Size of the source file before copy operation => ";
53var_dump( filesize("$src_file_name") );
54clearstatcache();
55
56echo "\n--- Now applying copy() on source file to create copies ---";
57$count = 1;
58foreach($dest_files as $dest_file) {
59  echo "\n-- Iteration $count --\n";
60  $dest_file_name = $file_path."/$dest_file";
61
62  echo "Copy operation => ";
63  var_dump( copy($src_file_name, $dest_file_name) );
64
65  echo "Existence of destination file => ";
66  var_dump( file_exists($dest_file_name) );
67
68  echo "Destination file name => ";
69  print($dest_file_name);
70  echo "\n";
71
72  echo "Size of source file => ";
73  var_dump( filesize($src_file_name) );
74  clearstatcache();
75
76  echo "Size of destination file => ";
77  var_dump( filesize($dest_file_name) );
78  clearstatcache();
79
80  unlink($dest_file_name);
81
82  $count++;
83}
84
85echo "*** Done ***\n";
86?>
87
88--CLEAN--
89<?php
90unlink(dirname(__FILE__)."/copy_variation2.tmp");
91?>
92
93--EXPECTF--
94*** Test copy() function: destination file names containing special characters ***
95Size of the source file before copy operation => int(1500)
96
97--- Now applying copy() on source file to create copies ---
98-- Iteration 1 --
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 2 --
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 3 --
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 4 --
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 5 --
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 6 --
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 7 --
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 8 --
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 9 --
155Copy operation => bool(true)
156Existence of destination file => bool(true)
157Destination file name => %s/!copy_variation2.tmp
158Size of source file => int(1500)
159Size of destination file => int(1500)
160
161-- Iteration 10 --
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 11 --
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 12 --
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 13 --
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 14 --
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 15 --
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 16 --
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 17 --
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 18 --
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 19 --
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
231-- Iteration 20 --
232Copy operation => bool(true)
233Existence of destination file => bool(true)
234Destination file name => %s/$copy_variation2.tmp
235Size of source file => int(1500)
236Size of destination file => int(1500)
237*** Done ***
238