1--TEST--
2Test copy() function: usage variations - non existing src/dest
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 create a copy of non-existing source in an existing destination
11     and an existing source in non-existing destiantion */
12
13$file_path = dirname(__FILE__);
14
15echo "*** Test copy() function: Trying to create a copy of non-existing source in existing destination ***";
16$file = $file_path."/copy_variation14.tmp";
17$file_handle =  fopen($file, "w");
18fwrite($file_handle, str_repeat(b"Hello2world...\n", 100));
19fclose($file_handle);
20
21var_dump( copy($file_path."/nosuchfile.tmp", $file_path."/copy_nosuchfile.tmp") );  //With non-existing source
22var_dump( file_exists($file_path."/copy_nosuchfile.tmp") );
23
24echo "\n*** Test copy() function: Trying to create copy of an existing source in non-existing destination ***";
25var_dump( copy($file, $file_path."/nodir/copy_nosuchfile.tmp") );  //With non-existing dir path
26var_dump( file_exists($file_path."/nodir/copy_nosuchfile.tmp") );
27var_dump( filesize($file) );  //size of the source
28
29echo "*** Done ***\n";
30?>
31
32--CLEAN--
33<?php
34unlink(dirname(__FILE__)."/copy_variation14.tmp");
35?>
36
37--EXPECTF--
38*** Test copy() function: Trying to create a copy of non-existing source in existing destination ***
39Warning: copy(%s): %s
40bool(false)
41bool(false)
42
43*** Test copy() function: Trying to create copy of an existing source in non-existing destination ***
44Warning: copy(%s): %s
45bool(false)
46bool(false)
47int(1500)
48*** Done ***
49