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