1--TEST--
2Test symlink(), linkinfo(), link() and is_link() functions : error conditions - link & is_link
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: bool symlink ( string $target, string $link );
12   Description: creates a symbolic link to the existing target with the specified name link
13
14   Prototype: bool is_link ( string $filename );
15   Description: Tells whether the given file is a symbolic link.
16
17   Prototype: bool link ( string $target, string $link );
18   Description: Create a hard link
19
20   Prototype: int linkinfo ( string $path );
21   Description: Gets information about a link
22*/
23
24// create temp $filename and create link $linkname to it
25$filename = dirname(__FILE__)."/symlink_link_linkinfo_is_link_error2.tmp";
26$fp = fopen($filename, "w");  // create temp file
27fclose($fp);
28
29// linkname used to create soft/hard link
30$linkname = dirname(__FILE__)."/symlink_link_linkinfo_is_link_link_error2.tmp";
31
32echo "*** Testing link() for error conditions ***\n";
33//zero arguments
34var_dump( link() );
35
36//more than expected
37var_dump( link($filename, $linkname, false) );
38
39//invalid arguments
40var_dump( link(NULL, $linkname) );  // NULL as filename
41var_dump( link('', $linkname) );  // empty string as filename
42var_dump( link(' ', $linkname) );  // space as filename
43var_dump( link(false, $linkname) );  // boolean false as filename
44var_dump( link($filename, NULL) );  // NULL as linkname
45var_dump( link($filename, '') );  // '' as linkname
46var_dump( link($filename, false) );  // false as linkname
47
48echo "\n*** Testing is_link() for error conditions ***\n";
49//zero arguments
50var_dump( is_link() );
51
52//more than expected
53var_dump( is_link($linkname, "/") );
54
55//invalid arguments
56var_dump( is_link(NULL) );  // NULL as linkname
57var_dump( is_link('') );  // empty string as linkname
58var_dump( is_link(' ') );  // space as linkname
59var_dump( is_link(false) );  // boolean false as linkname
60var_dump( is_link($filename) );  // file given to is_link
61
62echo "Done\n";
63?>
64--CLEAN--
65<?php
66unlink(dirname(__FILE__)."/symlink_link_linkinfo_is_link_error2.tmp");
67?>
68--EXPECTF--
69*** Testing link() for error conditions ***
70
71Warning: link() expects exactly 2 parameters, 0 given in %s on line %d
72NULL
73
74Warning: link() expects exactly 2 parameters, 3 given in %s on line %d
75NULL
76
77Warning: link(): No such file or directory in %s on line %d
78bool(false)
79
80Warning: link(): No such file or directory in %s on line %d
81bool(false)
82
83Warning: link(): No such file or directory in %s on line %d
84bool(false)
85
86Warning: link(): No such file or directory in %s on line %d
87bool(false)
88
89Warning: link(): No such file or directory in %s on line %d
90bool(false)
91
92Warning: link(): No such file or directory in %s on line %d
93bool(false)
94
95Warning: link(): No such file or directory in %s on line %d
96bool(false)
97
98*** Testing is_link() for error conditions ***
99
100Warning: is_link() expects exactly 1 parameter, 0 given in %s on line %d
101NULL
102
103Warning: is_link() expects exactly 1 parameter, 2 given in %s on line %d
104NULL
105bool(false)
106bool(false)
107bool(false)
108bool(false)
109bool(false)
110Done
111