1--TEST--
2Test copy() function: usage variations - stat after copy
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(): checking stat of file before and after after copy operation */
11
12$file_path = dirname(__FILE__);
13
14require($file_path."/file.inc");
15
16echo "*** Test copy() function: stat of file before and after copy ***\n";
17$src_file_name = $file_path."/copy_variation18.tmp";
18$file_handle =  fopen($src_file_name, "w");
19fwrite($file_handle, str_repeat("Hello2world...\n", 100));
20fclose($file_handle);
21
22$dest_file_name = $file_path."/copy_copy_variation18.tmp";
23
24clearstatcache();
25
26$stat_before_copy = stat($src_file_name);
27clearstatcache();
28
29echo "Copy operation => ";
30var_dump( copy($src_file_name, $dest_file_name) );
31
32$stat_after_copy = stat($src_file_name);
33clearstatcache();
34
35// compare all stat fields except access time
36$stat_keys_to_compare = array("dev", "ino", "mode", "nlink", "uid", "gid",
37                       "rdev", "size", "mtime", "ctime",
38                       "blksize", "blocks");
39
40echo "Comparing the stats of file before and after copy operation => ";
41var_dump( compare_stats($stat_before_copy, $stat_after_copy, $stat_keys_to_compare) );
42
43echo "*** Done ***\n";
44?>
45--CLEAN--
46<?php
47unlink(dirname(__FILE__)."/copy_copy_variation18.tmp");
48unlink(dirname(__FILE__)."/copy_variation18.tmp");
49?>
50--EXPECTF--
51*** Test copy() function: stat of file before and after copy ***
52Copy operation => bool(true)
53Comparing the stats of file before and after copy operation => bool(true)
54*** Done ***
55