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/* Prototype: bool copy ( string $source, string $dest );
12   Description: Makes a copy of the file source to dest.
13     Returns TRUE on success or FALSE on failure.
14*/
15
16/* Test copy(): Trying to copy source file to destination file with and without write permissions */
17
18$file_path = __DIR__;
19
20echo "*** Test copy() function: destination with/without write permissions ***\n";
21$src_file_name = $file_path."/copy_variation9.tmp";
22$file_handle =  fopen($src_file_name, "w");
23fwrite($file_handle, str_repeat("Hello2world...\n", 100));
24fclose($file_handle);
25
26$dest_file_name =  $file_path."/copy_copy_variation9.tmp";
27
28
29echo "\n-- With write permissions --\n";
30var_dump( file_exists($src_file_name) );
31var_dump( copy($src_file_name, $dest_file_name) );
32var_dump( file_exists($dest_file_name) );
33var_dump( filesize($dest_file_name) );
34
35echo "\n-- Without write permissions --\n";
36chmod($file_path."/copy_copy_variation9.tmp", 0555);  //No write permissions
37var_dump( file_exists($src_file_name) );
38var_dump( copy($src_file_name, $dest_file_name) );
39var_dump( file_exists($dest_file_name) );
40var_dump( filesize($dest_file_name) );
41
42echo "*** Done ***\n";
43?>
44--CLEAN--
45<?php
46unlink(__DIR__."/copy_copy_variation9.tmp");
47unlink(__DIR__."/copy_variation9.tmp");
48?>
49--EXPECTF--
50*** Test copy() function: destination with/without write permissions ***
51
52-- With write permissions --
53bool(true)
54bool(true)
55bool(true)
56int(1500)
57
58-- Without write permissions --
59bool(true)
60
61Warning: %s
62bool(false)
63bool(true)
64int(1500)
65*** Done ***
66