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 = dirname(__FILE__);
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(b"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
48--CLEAN--
49<?php
50unlink(dirname(__FILE__)."/copy_variation11.tmp");
51rmdir(dirname(__FILE__)."/copy_variation11");
52?>
53
54--EXPECTF--
55*** Test copy() function: Trying to create a copy of source file as a dir ***
56Size of source before copy operation => int(300)
57Size of destination before copy operation => int(%d)
58
59-- Now applying copy() operation --
60
61Warning: %s
62bool(false)
63bool(true)
64bool(true)
65bool(true)
66bool(false)
67bool(false)
68bool(true)
69int(300)
70int(%d)
71*** Done ***
72