1--TEST--
2Test symlink(), linkinfo(), link() and is_link() functions : usage variations - work on deleted 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/* Variation 5 : Creating link, deleting it and checking linkinfo(), is_link() on it */
25
26$file_path = dirname(__FILE__);
27
28echo "*** Testing linkinfo() and is_link() on deleted link ***\n";
29// link name used here
30$linkname  = "$file_path/symlink_link_linkinfo_is_link_link_variation5.tmp";
31
32// create temp dir
33$dirname = "$file_path/symlink_link_linkinfo_is_link_variation5";
34mkdir($dirname);
35
36// filename used here
37$filename = "$dirname/symlink_link_linkinfo_is_link_variation5.tmp";
38// create the file
39$fp = fopen($filename, "w");
40$data = "Hello World";
41fwrite($fp, $data);
42fclose($fp);
43
44var_dump( symlink($filename, $linkname) );  // create link
45
46// delete the link
47var_dump( unlink($linkname) );  // delete the link
48
49// clear the cache
50clearstatcache();
51
52// try using linkinfo() & is_link() on deleted link; expected: false
53$deleted_link = $linkname;
54var_dump( linkinfo($deleted_link) );
55var_dump( is_link($deleted_link) );
56
57echo "Done\n";
58?>
59--CLEAN--
60<?php
61$file_path = dirname(__FILE__);
62$dirname = "$file_path/symlink_link_linkinfo_is_link_variation5";
63$filename = "$dirname/symlink_link_linkinfo_is_link_variation5.tmp";
64unlink($filename);
65rmdir($dirname);
66?>
67--EXPECTF--
68*** Testing linkinfo() and is_link() on deleted link ***
69bool(true)
70bool(true)
71
72Warning: linkinfo(): No such file or directory in %s on line %d
73int(-1)
74bool(false)
75Done
76