1--TEST--
2Test readlink() and realpath() functions: error conditions
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip no symlinks on Windows');
7}
8?>
9--FILE--
10<?php
11/* Prototype: string readlink ( string $path );
12   Description: Returns the target of a symbolic link
13
14   Prototype: string realpath ( string $path );
15   Description: Returns canonicalized absolute pathname
16*/
17
18echo "*** Testing readlink(): error conditions ***\n";
19var_dump( readlink() );  // args < expected
20var_dump( readlink(__FILE__, 2) );  // args > expected
21
22echo "\n*** Testing readlink() on a non-existent link ***\n";
23var_dump( readlink(dirname(__FILE__)."/readlink_error.tmp") );
24
25echo "\n*** Testing readlink() on existing file ***\n";
26var_dump( readlink(__FILE__) );
27
28echo "\n*** Testing readlink() on existing directory ***\n";
29var_dump( readlink(dirname(__FILE__)) );
30
31echo "*** Testing realpath(): error conditions ***\n";
32var_dump( realpath() );  // args < expected
33var_dump( realpath(1, 2) );  // args > expected
34
35echo "\n*** Testing realpath() on a non-existent file ***\n";
36var_dump( realpath(dirname(__FILE__)."/realpath_error.tmp") );
37
38echo "Done\n";
39?>
40--EXPECTF--
41*** Testing readlink(): error conditions ***
42
43Warning: readlink() expects exactly 1 parameter, 0 given in %s on line %d
44NULL
45
46Warning: readlink() expects exactly 1 parameter, 2 given in %s on line %d
47NULL
48
49*** Testing readlink() on a non-existent link ***
50
51Warning: readlink(): No such file or directory in %s on line %d
52bool(false)
53
54*** Testing readlink() on existing file ***
55
56Warning: readlink(): Invalid argument in %s on line %d
57bool(false)
58
59*** Testing readlink() on existing directory ***
60
61Warning: readlink(): Invalid argument in %s on line %d
62bool(false)
63*** Testing realpath(): error conditions ***
64
65Warning: realpath() expects exactly 1 parameter, 0 given in %s on line %d
66NULL
67
68Warning: realpath() expects exactly 1 parameter, 2 given in %s on line %d
69NULL
70
71*** Testing realpath() on a non-existent file ***
72%s
73Done
74