1--TEST--
2Test copy() function: usage variations - destination file access perms
3--SKIPIF--
4<?php
5if(substr(PHP_OS, 0, 3) == 'WIN')
6  die("skip do not run on Windows");
7require __DIR__ . '/../skipif_root.inc';
8?>
9--FILE--
10<?php
11/* Test copy(): Trying to copy source file to destination file with and without write permissions */
12
13$file_path = __DIR__;
14
15echo "*** Test copy() function: destination with/without write permissions ***\n";
16$src_file_name = $file_path."/copy_variation9.tmp";
17$file_handle =  fopen($src_file_name, "w");
18fwrite($file_handle, str_repeat("Hello2world...\n", 100));
19fclose($file_handle);
20
21$dest_file_name =  $file_path."/copy_copy_variation9.tmp";
22
23
24echo "\n-- With write permissions --\n";
25var_dump( file_exists($src_file_name) );
26var_dump( copy($src_file_name, $dest_file_name) );
27var_dump( file_exists($dest_file_name) );
28var_dump( filesize($dest_file_name) );
29
30echo "\n-- Without write permissions --\n";
31chmod($file_path."/copy_copy_variation9.tmp", 0555);  //No write permissions
32var_dump( file_exists($src_file_name) );
33var_dump( copy($src_file_name, $dest_file_name) );
34var_dump( file_exists($dest_file_name) );
35var_dump( filesize($dest_file_name) );
36
37echo "*** Done ***\n";
38?>
39--CLEAN--
40<?php
41unlink(__DIR__."/copy_copy_variation9.tmp");
42unlink(__DIR__."/copy_variation9.tmp");
43?>
44--EXPECTF--
45*** Test copy() function: destination with/without write permissions ***
46
47-- With write permissions --
48bool(true)
49bool(true)
50bool(true)
51int(1500)
52
53-- Without write permissions --
54bool(true)
55
56Warning: %s
57bool(false)
58bool(true)
59int(1500)
60*** Done ***
61