1--TEST--
2Test symlink(), linkinfo(), link() and is_link() functions : error conditions - symlink & linkinfo
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip no symlinks on Windows');
7}
8if (substr(PHP_OS, 0, 3) == 'SUN') {
9  die('skip Not valid for Sun Solaris');
10}
11if (PHP_INT_SIZE != 4) {
12  die("skip this test is for 32bit platform only");
13}
14?>
15--FILE--
16<?php
17/* Prototype: bool symlink ( string $target, string $link );
18   Description: creates a symbolic link to the existing target with the specified name link
19
20   Prototype: bool is_link ( string $filename );
21   Description: Tells whether the given file is a symbolic link.
22
23   Prototype: bool link ( string $target, string $link );
24   Description: Create a hard link
25
26   Prototype: int linkinfo ( string $path );
27   Description: Gets information about a link
28*/
29
30// create temp $filename and create link $linkname to it
31$filename = dirname(__FILE__)."/symlink_link_linkinfo_is_link_error1.tmp";
32$fp = fopen($filename, "w");  // create temp file
33fclose($fp);
34
35// linkname used to create soft/hard link
36$linkname = dirname(__FILE__)."/symlink_link_linkinfo_is_link_link_error1.tmp";
37
38echo "*** Testing symlink() for error conditions ***\n";
39//zero arguments
40var_dump( symlink() );
41
42//more than expected
43var_dump( symlink($filename, $linkname, true) );
44
45//invalid arguments
46var_dump( symlink(NULL, $linkname) );  // NULL as filename
47var_dump( symlink('', $linkname) );  // empty string as filename
48var_dump( symlink(false, $linkname) );  // boolean false as filename
49var_dump( symlink($filename, NULL) );  // NULL as linkname
50var_dump( symlink($filename, '') );  // '' as linkname
51var_dump( symlink($filename, false) );  // false as linkname
52
53echo "\n*** Testing linkinfo() for error conditions ***\n";
54//zero arguments
55var_dump( linkinfo() );
56
57//more than expected
58var_dump( linkinfo($linkname, true) );
59
60//invalid arguments
61var_dump( linkinfo(NULL) );  // NULL as linkname
62var_dump( linkinfo('') );  // empty string as linkname
63var_dump( linkinfo(false) );  // boolean false as linkname
64
65echo "Done\n";
66?>
67--CLEAN--
68<?php
69unlink(dirname(__FILE__)."/symlink_link_linkinfo_is_link_error1.tmp");
70@unlink(dirname(__FILE__)."/symlink_link_linkinfo_is_link_link_error1.tmp");
71?>
72--EXPECTF--
73*** Testing symlink() for error conditions ***
74
75Warning: symlink() expects exactly 2 parameters, 0 given in %s on line %d
76NULL
77
78Warning: symlink() expects exactly 2 parameters, 3 given in %s on line %d
79NULL
80
81Warning: symlink(): %s in %s on line %d
82bool(false)
83
84Warning: symlink(): %s in %s on line %d
85bool(false)
86
87Warning: symlink(): %s in %s on line %d
88bool(false)
89
90Warning: symlink(): %s in %s on line %d
91bool(false)
92
93Warning: symlink(): %s in %s on line %d
94bool(false)
95
96Warning: symlink(): %s in %s on line %d
97bool(false)
98
99*** Testing linkinfo() for error conditions ***
100
101Warning: linkinfo() expects exactly 1 parameter, 0 given in %s on line %d
102NULL
103
104Warning: linkinfo() expects exactly 1 parameter, 2 given in %s on line %d
105NULL
106
107Warning: linkinfo(): %s in %s on line %d
108int(-1)
109
110Warning: linkinfo(): %s in %s on line %d
111int(-1)
112
113Warning: linkinfo(): %s in %s on line %d
114int(-1)
115Done
116