1--TEST--
2Test copy() function: usage variations - existing dir as destination
3--FILE--
4<?php
5/* Prototype: bool copy ( string $source, string $dest );
6   Description: Makes a copy of the file source to dest.
7     Returns TRUE on success or FALSE on failure.
8*/
9
10/* Test copy(): Trying to copy the file to a destination, where destination is an existing dir */
11
12$file_path = __DIR__;
13
14echo "*** Test copy() function: Trying to create a copy of source file as a dir ***\n";
15$file = $file_path."/copy_variation11.tmp";
16$file_handle =  fopen($file, "w");
17fwrite($file_handle, str_repeat("Hello, world...", 20));
18fclose($file_handle);
19
20$dir = $file_path."/copy_variation11";
21mkdir($dir);
22
23echo "Size of source before copy operation => ";
24var_dump( filesize($file) );  //size of source before copy
25clearstatcache();
26echo "Size of destination before copy operation => ";
27var_dump( filesize($dir) );  //size of destination before copy
28clearstatcache();
29
30echo "\n-- Now applying copy() operation --\n";
31var_dump( copy($file, $dir) );  //expected: bool(false)
32
33var_dump( file_exists($file) );  //expected: bool(true)
34var_dump( file_exists($dir) );  //expected: bool(true)
35
36var_dump( is_file($file) );  //expected: bool(true)
37var_dump( is_dir($file) );  //expected: bool(false)
38
39var_dump( is_file($dir) ); //expected: bool(false)
40var_dump( is_dir($dir) );  //expected: bool(true)
41
42var_dump( filesize($file) );   //size of source after copy
43var_dump( filesize($dir) );   //size of destination after copy
44
45echo "*** Done ***\n";
46?>
47--CLEAN--
48<?php
49unlink(__DIR__."/copy_variation11.tmp");
50rmdir(__DIR__."/copy_variation11");
51?>
52--EXPECTF--
53*** Test copy() function: Trying to create a copy of source file as a dir ***
54Size of source before copy operation => int(300)
55Size of destination before copy operation => int(%d)
56
57-- Now applying copy() operation --
58
59Warning: %s
60bool(false)
61bool(true)
62bool(true)
63bool(true)
64bool(false)
65bool(false)
66bool(true)
67int(300)
68int(%d)
69*** Done ***
70