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("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--CLEAN--
32<?php
33unlink(dirname(__FILE__)."/copy_variation14.tmp");
34?>
35--EXPECTF--
36*** Test copy() function: Trying to create a copy of non-existing source in existing destination ***
37Warning: copy(%s): %s
38bool(false)
39bool(false)
40
41*** Test copy() function: Trying to create copy of an existing source in non-existing destination ***
42Warning: copy(%s): %s
43bool(false)
44bool(false)
45int(1500)
46*** Done ***
47