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
37--CLEAN--
38<?php
39unlink(dirname(__FILE__)."/copy_variation13_dir.tmp");
40rmdir(dirname(__FILE__)."/copy_variation13");
41?>
42
43--EXPECTF--
44*** Test copy() function: Trying to copy dir to file ***
45*** Testing copy() in copying dir to file ***
46
47Warning: copy(): The first argument to copy() function cannot be a directory in %scopy_variation13.php on line %d
48bool(false)
49bool(true)
50bool(true)
51bool(false)
52bool(true)
53bool(true)
54bool(false)
55int(%d)
56int(%d)
57*** Done ***
58