Annotation of embedaddon/php/ext/standard/tests/file/unlink_variation3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test unlink() function : usage variations - unlink links
3: --SKIPIF--
4: <?php
5: if (substr(PHP_OS, 0, 3) == 'WIN') {
6: die('skip only on Linux');
7: }
8: ?>
9: --FILE--
10: <?php
11: /* Prototype : bool unlink ( string $filename [, resource $context] );
12: Description : Deletes filename
13: */
14:
15: /* Delete link files - soft and hard links */
16:
17: $file_path = dirname(__FILE__);
18: // temp file used
19: $filename = "$file_path/unlink_variation3.tmp";
20:
21: echo "*** Testing unlink() on soft and hard links ***\n";
22: // create temp file
23: $fp = fopen($filename, "w");
24: fclose($fp);
25: // link name used here
26: $linkname = "$file_path/unlink_variation3_link.tmp";
27:
28: echo "-- Testing unlink() on soft link --\n";
29: // create soft link
30: var_dump( symlink($filename, $linkname) ); // expected: true
31: // unlink soft link
32: var_dump( unlink($linkname) ); // expected: true
33: var_dump( file_exists($linkname) ); // confirm link is deleted
34:
35: echo "-- Testing unlink() on hard link --\n";
36: // create hard link
37: var_dump( link($filename, $linkname) ); // expected: true
38: // delete hard link
39: var_dump( unlink($linkname) ); // expected: true
40: var_dump( file_exists($linkname) ); // confirm link is deleted
41:
42: // delete temp file
43: var_dump( unlink($filename) );
44: var_dump( file_exists($filename) ); // confirm file is deleted
45:
46: echo "Done\n";
47: ?>
48: --EXPECTF--
49: *** Testing unlink() on soft and hard links ***
50: -- Testing unlink() on soft link --
51: bool(true)
52: bool(true)
53: bool(false)
54: -- Testing unlink() on hard link --
55: bool(true)
56: bool(true)
57: bool(false)
58: bool(true)
59: bool(false)
60: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>