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