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