1--TEST--
2Test copy() function: usage variations - copy empty file across dirs
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/* Test copy() function: Trying to create copy of source file
11     into different destination dir paths given in various notations */
12
13echo "*** Test copy() function: copying file across directories ***\n";
14$base_dir = __DIR__."/copy_variation6";
15mkdir($base_dir);
16
17$sub_dir = $base_dir."/copy_variation6_sub";
18mkdir($sub_dir);
19
20$dirname_with_blank = $sub_dir."/copy variation6";
21mkdir($dirname_with_blank);
22
23$src_file_name = __DIR__."/copy_variation6.tmp";
24fclose( fopen($src_file_name, "w") );
25
26echo "Size of source file => ";
27var_dump( filesize($src_file_name) );
28clearstatcache();
29
30$dests = array(
31  $base_dir."/copy_copy_variation6.tmp",
32  $base_dir."/copy_variation6_sub/copy_copy_variation6.tmp",
33  "$sub_dir/copy_copy_variation6.tmp",
34  "$sub_dir/../copy_copy_variation6.tmp",
35  "$sub_dir/../copy_variation6_sub/copy_copy_variation6.tmp",
36  "$sub_dir/..///../copy_copy_variation6.tmp",
37  "$sub_dir///../*",
38  "$dirname_with_blank/copy_copy_variation6.tmp"
39);
40
41echo "\n-- Now applying copy() on source file to create copies --";
42$count = 1;
43foreach($dests as $dest) {
44  echo "\n-- Iteration $count --\n";
45
46  echo "Copy operation => ";
47  var_dump( copy($src_file_name, $dest) );
48
49  echo "Existence of destination file => ";
50  var_dump( file_exists($dest) );
51
52  echo "Destination file name is => ";
53  print($dest);
54  echo "\n";
55
56  echo "Size of source file => ";
57  var_dump( filesize($src_file_name) );
58  clearstatcache();
59
60  echo "Size of destination file => ";
61  var_dump( filesize($dest) );
62  clearstatcache();
63
64  unlink("$dest");
65
66  $count++;
67}
68
69unlink($src_file_name);
70rmdir($dirname_with_blank);
71rmdir($sub_dir);
72rmdir($base_dir);
73
74echo "*** Done ***\n";
75?>
76--EXPECTF--
77*** Test copy() function: copying file across directories ***
78Size of source file => int(0)
79
80-- Now applying copy() on source file to create copies --
81-- Iteration 1 --
82Copy operation => bool(true)
83Existence of destination file => bool(true)
84Destination file name is => %s/copy_variation6/copy_copy_variation6.tmp
85Size of source file => int(0)
86Size of destination file => int(0)
87
88-- Iteration 2 --
89Copy operation => bool(true)
90Existence of destination file => bool(true)
91Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp
92Size of source file => int(0)
93Size of destination file => int(0)
94
95-- Iteration 3 --
96Copy operation => bool(true)
97Existence of destination file => bool(true)
98Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp
99Size of source file => int(0)
100Size of destination file => int(0)
101
102-- Iteration 4 --
103Copy operation => bool(true)
104Existence of destination file => bool(true)
105Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_copy_variation6.tmp
106Size of source file => int(0)
107Size of destination file => int(0)
108
109-- Iteration 5 --
110Copy operation => bool(true)
111Existence of destination file => bool(true)
112Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_variation6_sub/copy_copy_variation6.tmp
113Size of source file => int(0)
114Size of destination file => int(0)
115
116-- Iteration 6 --
117Copy operation => bool(true)
118Existence of destination file => bool(true)
119Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../copy_copy_variation6.tmp
120Size of source file => int(0)
121Size of destination file => int(0)
122
123-- Iteration 7 --
124Copy operation => bool(true)
125Existence of destination file => bool(true)
126Destination file name is => %s/copy_variation6/copy_variation6_sub///../*
127Size of source file => int(0)
128Size of destination file => int(0)
129
130-- Iteration 8 --
131Copy operation => bool(true)
132Existence of destination file => bool(true)
133Destination file name is => %s/copy_variation6/copy_variation6_sub/copy variation6/copy_copy_variation6.tmp
134Size of source file => int(0)
135Size of destination file => int(0)
136*** Done ***
137