1--TEST--
2Test copy() function: usage variations - src as dir and dest as an existing file(Bug #42243)
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 dir to an existing file */
11
12echo "*** Test copy() function: Trying to copy dir to file ***\n";
13$file_path = dirname(__FILE__);
14$file = $file_path."/copy_variation13_dir.tmp";
15fclose(fopen($file, "w"));
16$dir = $file_path."/copy_variation13";
17mkdir($dir);
18
19echo "*** Testing copy() in copying dir to file ***\n";
20var_dump( copy($dir, $file) );
21
22var_dump( file_exists($file) );
23var_dump( file_exists($dir) );
24
25var_dump( is_file($dir) );
26var_dump( is_dir($dir) );
27
28var_dump( is_file($file) );
29var_dump( is_dir($file) );
30
31var_dump( filesize($file) );
32var_dump( filesize($dir) );
33
34echo "*** Done ***\n";
35?>
36--CLEAN--
37<?php
38unlink(dirname(__FILE__)."/copy_variation13_dir.tmp");
39rmdir(dirname(__FILE__)."/copy_variation13");
40?>
41--EXPECTF--
42*** Test copy() function: Trying to copy dir to file ***
43*** Testing copy() in copying dir to file ***
44
45Warning: copy(): The first argument to copy() function cannot be a directory in %scopy_variation13.php on line %d
46bool(false)
47bool(true)
48bool(true)
49bool(false)
50bool(true)
51bool(true)
52bool(false)
53int(%d)
54int(%d)
55*** Done ***
56