Annotation of embedaddon/php/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation5.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test symlink(), linkinfo(), link() and is_link() functions : usage variations - work on deleted link
                      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: 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: 
                     28: echo "*** 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";
                     34: mkdir($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";
                     41: fwrite($fp, $data);
                     42: fclose($fp);
                     43: 
                     44: var_dump( symlink($filename, $linkname) );  // create link
                     45: 
                     46: // delete the link
                     47: var_dump( unlink($linkname) );  // delete the link
                     48: 
                     49: // clear the cache
                     50: clearstatcache();
                     51: 
                     52: // try using linkinfo() & is_link() on deleted link; expected: false
                     53: $deleted_link = $linkname;
                     54: var_dump( linkinfo($deleted_link) );
                     55: var_dump( is_link($deleted_link) );
                     56: 
                     57: echo "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";
                     64: unlink($filename);
                     65: rmdir($dirname);
                     66: ?>
                     67: --EXPECTF--
                     68: *** Testing linkinfo() and is_link() on deleted link ***
                     69: bool(true)
                     70: bool(true)
                     71: 
                     72: Warning: linkinfo(): No such file or directory in %s on line %d
                     73: int(-1)
                     74: bool(false)
                     75: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>