Annotation of embedaddon/php/ext/standard/tests/file/lchown_error.phpt, revision 1.1.1.3
1.1 misho 1: --TEST--
2: Test lchown() function : error functionality
3: --SKIPIF--
4: <?php
5: if (substr(PHP_OS, 0, 3) == 'WIN') die('skip no windows support');
6: if (!function_exists("posix_getuid")) die("skip no posix_getuid()");
7: // Skip if being run by root
8: $filename = dirname(__FILE__)."/is_readable_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 lchown (string filename, mixed user)
20: * Description: Change file owner of a symlink
21: * Source code: ext/standard/filestat.c
22: * Alias to functions:
23: */
24:
25: echo "*** Testing lchown() : error functionality ***\n";
26:
27: // Set up
28: $filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchown.txt';
29: touch( $filename );
30: $uid = posix_getuid();
31:
32:
33: // Less than expected arguments
34: var_dump( lchown( $filename ) );
35:
36: // More than expected arguments
37: var_dump( lchown( $filename, $uid, 'foobar' ) );
38:
1.1.1.3 ! misho 39: // Non-existent filename
1.1 misho 40: var_dump( lchown( 'foobar_lchown.txt', $uid ) );
41:
42: // Wrong argument types
43: var_dump( lchown( new StdClass(), $uid ) );
44: var_dump( lchown( array(), $uid ) );
45:
46: // Bad user
47: var_dump( lchown( $filename, -5 ) );
48:
49: ?>
50: ===DONE===
51: --CLEAN--
52: <?php
53:
54: $filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchown.txt';
55: unlink($filename);
56:
57: ?>
58: --EXPECTF--
59: *** Testing lchown() : error functionality ***
60:
61: Warning: lchown() expects exactly 2 parameters, 1 given in %s on line %d
62: bool(true)
63:
64: Warning: lchown() expects exactly 2 parameters, 3 given in %s on line %d
65: bool(true)
66:
67: Warning: lchown(): No such file or directory in %s on line %d
68: bool(false)
69:
1.1.1.2 misho 70: Warning: lchown() expects parameter 1 to be a valid path, object given in %s on line %d
1.1 misho 71: bool(true)
72:
1.1.1.2 misho 73: Warning: lchown() expects parameter 1 to be a valid path, array given in %s on line %d
1.1 misho 74: bool(true)
75:
76: Warning: lchown(): Operation not permitted in %s on line %d
77: bool(false)
78: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>