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("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--CLEAN--
88<?php
89unlink(dirname(__FILE__)."/copy_variation2.tmp");
90?>
91--EXPECTF--
92*** Test copy() function: destination file names containing special characters ***
93Size of the source file before copy operation => int(1500)
94
95--- Now applying copy() on source file to create copies ---
96-- Iteration 1 --
97Copy operation => bool(true)
98Existence of destination file => bool(true)
99Destination file name => %s/_copy_variation2.tmp
100Size of source file => int(1500)
101Size of destination file => int(1500)
102
103-- Iteration 2 --
104Copy operation => bool(true)
105Existence of destination file => bool(true)
106Destination file name => %s/@copy_variation2.tmp
107Size of source file => int(1500)
108Size of destination file => int(1500)
109
110-- Iteration 3 --
111Copy operation => bool(true)
112Existence of destination file => bool(true)
113Destination file name => %s/#copy_variation2.tmp
114Size of source file => int(1500)
115Size of destination file => int(1500)
116
117-- Iteration 4 --
118Copy operation => bool(true)
119Existence of destination file => bool(true)
120Destination file name => %s/+copy_variation2.tmp
121Size of source file => int(1500)
122Size of destination file => int(1500)
123
124-- Iteration 5 --
125Copy operation => bool(true)
126Existence of destination file => bool(true)
127Destination file name => %s/*copy_variation2.tmp
128Size of source file => int(1500)
129Size of destination file => int(1500)
130
131-- Iteration 6 --
132Copy operation => bool(true)
133Existence of destination file => bool(true)
134Destination file name => %s/?copy_variation2.tmp
135Size of source file => int(1500)
136Size of destination file => int(1500)
137
138-- Iteration 7 --
139Copy operation => bool(true)
140Existence of destination file => bool(true)
141Destination file name => %s/<copy_variation2.tmp
142Size of source file => int(1500)
143Size of destination file => int(1500)
144
145-- Iteration 8 --
146Copy operation => bool(true)
147Existence of destination file => bool(true)
148Destination file name => %s/>copy_variation2.tmp
149Size of source file => int(1500)
150Size of destination file => int(1500)
151
152-- Iteration 9 --
153Copy operation => bool(true)
154Existence of destination file => bool(true)
155Destination file name => %s/!copy_variation2.tmp
156Size of source file => int(1500)
157Size of destination file => int(1500)
158
159-- Iteration 10 --
160Copy operation => bool(true)
161Existence of destination file => bool(true)
162Destination file name => %s/&copy_variation2.tmp
163Size of source file => int(1500)
164Size of destination file => int(1500)
165
166-- Iteration 11 --
167Copy operation => bool(true)
168Existence of destination file => bool(true)
169Destination file name => %s/(copy_variation2.tmp
170Size of source file => int(1500)
171Size of destination file => int(1500)
172
173-- Iteration 12 --
174Copy operation => bool(true)
175Existence of destination file => bool(true)
176Destination file name => %s/:copy_variation2.tmp
177Size of source file => int(1500)
178Size of destination file => int(1500)
179
180-- Iteration 13 --
181Copy operation => bool(true)
182Existence of destination file => bool(true)
183Destination file name => %s/;copy_variation2.tmp
184Size of source file => int(1500)
185Size of destination file => int(1500)
186
187-- Iteration 14 --
188Copy operation => bool(true)
189Existence of destination file => bool(true)
190Destination file name => %s/=copy_variation2.tmp
191Size of source file => int(1500)
192Size of destination file => int(1500)
193
194-- Iteration 15 --
195Copy operation => bool(true)
196Existence of destination file => bool(true)
197Destination file name => %s/[copy_variation2.tmp
198Size of source file => int(1500)
199Size of destination file => int(1500)
200
201-- Iteration 16 --
202Copy operation => bool(true)
203Existence of destination file => bool(true)
204Destination file name => %s/^copy_variation2.tmp
205Size of source file => int(1500)
206Size of destination file => int(1500)
207
208-- Iteration 17 --
209Copy operation => bool(true)
210Existence of destination file => bool(true)
211Destination file name => %s/{copy_variation2.tmp
212Size of source file => int(1500)
213Size of destination file => int(1500)
214
215-- Iteration 18 --
216Copy operation => bool(true)
217Existence of destination file => bool(true)
218Destination file name => %s/|copy_variation2.tmp
219Size of source file => int(1500)
220Size of destination file => int(1500)
221
222-- Iteration 19 --
223Copy operation => bool(true)
224Existence of destination file => bool(true)
225Destination file name => %s/~copy_variation2.tmp
226Size of source file => int(1500)
227Size of destination file => int(1500)
228
229-- Iteration 20 --
230Copy operation => bool(true)
231Existence of destination file => bool(true)
232Destination file name => %s/$copy_variation2.tmp
233Size of source file => int(1500)
234Size of destination file => int(1500)
235*** Done ***
236