Annotation of embedaddon/php/ext/standard/tests/file/copy_variation15.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test copy() function: usage variations - destination dir access perms
3: --SKIPIF--
4: <?php
5: if(substr(PHP_OS, 0, 3) == 'WIN')
6: die("skip do not run on Windows");
7: // Skip if being run by root (files are always readable, writeable and executable)
8: $filename = dirname(__FILE__)."/copy_variation15_root_check.tmp";
9: $fp = fopen($filename, 'w');
10: fclose($fp);
11: if(fileowner($filename) == 0) {
12: unlink ($filename);
13: die('skip cannot be run as root');
14: }
15: unlink($filename);
16: ?>
17: --FILE--
18: <?php
19: /* Prototype: bool copy ( string $source, string $dest );
20: Description: Makes a copy of the file source to dest.
21: Returns TRUE on success or FALSE on failure.
22: */
23:
24: /* Test copy(): Trying to create a copy of file in a dir which doesn't have write permissions */
25:
26: $file_path = dirname(__FILE__);
27:
28: echo "*** Test copy() function: Trying to create a copy of file in a dir which doesn't have write permissions ***";
29: $file = $file_path."/copy_variation15.tmp";
30: $file_handle = fopen($file, "w");
31: fwrite($file_handle, str_repeat(b"Hello, world...", 20));
32: fclose($file_handle);
33:
34: $dir = $file_path."/copy_variation15";
35: mkdir($dir);
36:
37: $old_perms = fileperms($dir);
38:
39: chmod($dir, 0555); //dir without write permissions
40:
41: $dest = $dir."/copy_copy_variation15.tmp";
42:
43: var_dump( copy($file, $dir."/copy_copy_variation15.tmp") );
44: var_dump( file_exists($dir."/copy_copy_variation15_dir.tmp") );
45: var_dump( filesize($file) ); //size of source
46:
47: chmod($dir, $old_perms);
48:
49: echo "*** Done ***\n";
50: ?>
51:
52: --CLEAN--
53: <?php
54: unlink(dirname(__FILE__)."/copy_variation15.tmp");
55: rmdir(dirname(__FILE__)."/copy_variation15");
56: ?>
57:
58: --EXPECTF--
59: *** Test copy() function: Trying to create a copy of file in a dir which doesn't have write permissions ***
60: Warning: copy(%s): %s
61: bool(false)
62: bool(false)
63: int(300)
64: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>