1--TEST--
2Test lchown() function : error functionality
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') die('skip no windows support');
6if (!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');
10fclose($fp);
11if(fileowner($filename) == 0) {
12        unlink ($filename);
13        die('skip cannot be run as root');
14}
15unlink($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
25echo "*** Testing lchown() : error functionality ***\n";
26
27// Set up
28$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchown.txt';
29touch( $filename );
30$uid = posix_getuid();
31
32
33// Less than expected arguments
34var_dump( lchown( $filename ) );
35
36// More than expected arguments
37var_dump( lchown( $filename, $uid, 'foobar' ) );
38
39// Non-existant filename
40var_dump( lchown( 'foobar_lchown.txt', $uid ) );
41
42// Wrong argument types
43var_dump( lchown( new StdClass(), $uid ) );
44var_dump( lchown( array(), $uid ) );
45
46// Bad user
47var_dump( lchown( $filename, -5 ) );
48
49?>
50===DONE===
51--CLEAN--
52<?php
53
54$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchown.txt';
55unlink($filename);
56
57?>
58--EXPECTF--
59*** Testing lchown() : error functionality ***
60
61Warning: lchown() expects exactly 2 parameters, 1 given in %s on line %d
62bool(true)
63
64Warning: lchown() expects exactly 2 parameters, 3 given in %s on line %d
65bool(true)
66
67Warning: lchown(): No such file or directory in %s on line %d
68bool(false)
69
70Warning: lchown() expects parameter 1 to be string, object given in %s on line %d
71bool(true)
72
73Warning: lchown() expects parameter 1 to be string, array given in %s on line %d
74bool(true)
75
76Warning: lchown(): Operation not permitted in %s on line %d
77bool(false)
78===DONE===
79