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()");
7require __DIR__ . '/../skipif_root.inc';
8?>
9--FILE--
10<?php
11/* Prototype  : bool lchown (string filename, mixed user)
12 * Description: Change file owner of a symlink
13 * Source code: ext/standard/filestat.c
14 * Alias to functions:
15 */
16
17echo "*** Testing lchown() : error functionality ***\n";
18
19// Set up
20$filename = __DIR__ . DIRECTORY_SEPARATOR . 'lchown.txt';
21touch( $filename );
22$uid = posix_getuid();
23
24
25// Less than expected arguments
26var_dump( lchown( $filename ) );
27
28// More than expected arguments
29var_dump( lchown( $filename, $uid, 'foobar' ) );
30
31// Non-existent filename
32var_dump( lchown( 'foobar_lchown.txt', $uid ) );
33
34// Wrong argument types
35var_dump( lchown( new StdClass(), $uid ) );
36var_dump( lchown( array(), $uid ) );
37
38// Bad user
39var_dump( lchown( $filename, -5 ) );
40
41?>
42===DONE===
43--CLEAN--
44<?php
45
46$filename = __DIR__ . DIRECTORY_SEPARATOR . 'lchown.txt';
47unlink($filename);
48
49?>
50--EXPECTF--
51*** Testing lchown() : error functionality ***
52
53Warning: lchown() expects exactly 2 parameters, 1 given in %s on line %d
54bool(true)
55
56Warning: lchown() expects exactly 2 parameters, 3 given in %s on line %d
57bool(true)
58
59Warning: lchown(): No such file or directory in %s on line %d
60bool(false)
61
62Warning: lchown() expects parameter 1 to be a valid path, object given in %s on line %d
63bool(true)
64
65Warning: lchown() expects parameter 1 to be a valid path, array given in %s on line %d
66bool(true)
67
68Warning: lchown(): %r(Operation not permitted|Invalid argument)%r in %s on line %d
69bool(false)
70===DONE===
71