Annotation of embedaddon/php/ext/standard/tests/file/readlink_realpath_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test readlink() and realpath() functions: usage variation - linkname/filename stored in array(Bug #42038)
3: --SKIPIF--
4: <?php
5: if (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:
18: echo "*** Testing readlink() and realpath() : usage variations ***\n";
19: $name_prefix = dirname(__FILE__);
20: // create temp dir
21: mkdir("$name_prefix/readlink_realpath_variation2/home/tests/link/", 0777, true);
22: // create the file
23: $filename = "$name_prefix/readlink_realpath_variation2/home/tests/link/readlink_realpath_variation2.tmp";
24: $fp = fopen($filename, "w");
25: fclose($fp);
26:
27: echo "\n*** Testing readlink() and realpath() with linkname stored in an array ***\n";
28: $link_arr = array (
29: "$name_prefix////readlink_realpath_variation2/home/tests/link/readlink_realpath_variation2_link.tmp",
30: "$name_prefix/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/"
31: );
32:
33: echo "\n-- Testing readlink() and realpath() with softlink, linkname stored inside an array --\n";
34: // creating the links
35: var_dump( symlink($filename, $link_arr[0]) );
36: var_dump( readlink($link_arr[0]) );
37: var_dump( realpath($link_arr[0]) );
38: var_dump( symlink($filename, $link_arr[1]) );
39: var_dump( readlink($link_arr[1]) );
40: var_dump( realpath($link_arr[1]) );
41:
42: // deleting the link
43: unlink($link_arr[0]);
44: unlink($link_arr[1]);
45:
46: echo "\n-- Testing readlink() and realpath() with hardlink, linkname stored inside an array --\n";
47: // creating hard links
48: var_dump( link($filename, $link_arr[0]) );
49: var_dump( readlink($link_arr[0]) ); // invalid because readlink doesn't work with hardlink
50: var_dump( realpath($link_arr[0]) );
51: var_dump( link($filename, $link_arr[1]) );
52: var_dump( readlink($link_arr[1]) ); // invalid because readlink doesn't work with hardlink
53: var_dump( realpath($link_arr[1]) );
54:
55: // delete the links
56: unlink($link_arr[0]);
57: unlink($link_arr[1]);
58:
59: echo "Done\n";
60: ?>
61: --CLEAN--
62: <?php
63: $name_prefix = dirname(__FILE__)."/readlink_realpath_variation2";
64: unlink("$name_prefix/home/tests/link/readlink_realpath_variation2.tmp");
65: rmdir("$name_prefix/home/tests/link/");
66: rmdir("$name_prefix/home/tests/");
67: rmdir("$name_prefix/home/");
68: rmdir("$name_prefix/");
69: ?>
70: --EXPECTF--
71: *** Testing readlink() and realpath() : usage variations ***
72:
73: *** Testing readlink() and realpath() with linkname stored in an array ***
74:
75: -- Testing readlink() and realpath() with softlink, linkname stored inside an array --
76: bool(true)
77: string(%d) "%s/readlink_realpath_variation2/home/tests/link/readlink_realpath_variation2.tmp"
78: string(%d) "%s/readlink_realpath_variation2/home/tests/link/readlink_realpath_variation2.tmp"
79:
80: Warning: symlink(): No such file or directory in %s on line %d
81: bool(false)
82:
83: Warning: readlink(): No such file or directory in %s on line %d
84: bool(false)
85: bool(false)
86:
87: Warning: unlink(%s/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/): No such file or directory in %s on line %d
88:
89: -- Testing readlink() and realpath() with hardlink, linkname stored inside an array --
90: bool(true)
91:
92: Warning: readlink(): Invalid argument in %s on line %d
93: bool(false)
94: string(%d) "%s/readlink_realpath_variation2/home/tests/link/readlink_realpath_variation2_link.tmp"
95:
96: Warning: link(): No such file or directory in %s on line %d
97: bool(false)
98:
99: Warning: readlink(): No such file or directory in %s on line %d
100: bool(false)
101: bool(false)
102:
103: Warning: unlink(%s/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/): No such file or directory in %s on line %d
104: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>