Annotation of embedaddon/php/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic2.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test symlink(), linkinfo(), link() and is_link() functions: basic functionality - link to dirs
        !             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: $file_path = dirname(__FILE__);
        !            25: 
        !            26: echo "*** Testing symlink(), linkinfo(), link() and is_link() : basic functionality ***\n";
        !            27: 
        !            28: /* Creating soft/hard link to the temporary dir $dirname and checking
        !            29:    linkinfo() and is_link() on the link created to $dirname */
        !            30: 
        !            31: $dirname = "symlink_link_linkinfo_is_link_basic2";
        !            32: mkdir($file_path."/".$dirname);
        !            33: 
        !            34: echo "\n*** Testing symlink(), linkinfo(), link() and is_link() on directory ***\n";
        !            35: 
        !            36: // name of the soft link created to $dirname
        !            37: $sym_linkname = "$file_path/$dirname/symlink_link_linkinfo_is_link_softlink_basic2.tmp";
        !            38: 
        !            39: // name of the hard link created to $dirname
        !            40: $linkname = "$file_path/$dirname/symlink_link_linkinfo_is_link_hardlink_basic2.tmp";
        !            41: 
        !            42: // testing on soft link
        !            43: echo "\n-- Testing on soft links --\n";
        !            44: // creating soft link to $dirname
        !            45: var_dump( symlink("$file_path/$dirname", $sym_linkname) ); // this works, expected true
        !            46: // gets information about soft link created to directory; expected: true
        !            47: var_dump( linkinfo($sym_linkname) );
        !            48: // checks if link created is soft link; expected: true
        !            49: var_dump( is_link($sym_linkname) );
        !            50: // clear the cache
        !            51: clearstatcache();
        !            52: 
        !            53: // testing on hard link
        !            54: echo "\n-- Testing on hard links --\n";
        !            55: // creating hard link to $dirname; expected: false
        !            56: var_dump( link("$file_path/$dirname", $linkname) ); // this doesn't work, expected false
        !            57: var_dump( linkinfo($linkname) ); // link doesn't exists as not created, expected false
        !            58: var_dump( is_link($linkname) ); // link doesn't exists as not created, expected false
        !            59: // clear the cache
        !            60: clearstatcache();
        !            61: 
        !            62: // deleting the links
        !            63: unlink($sym_linkname);
        !            64: 
        !            65: echo "Done\n";
        !            66: ?>
        !            67: --CLEAN--
        !            68: <?php
        !            69: $dirname = dirname(__FILE__)."/symlink_link_linkinfo_is_link_basic2";
        !            70: rmdir($dirname);
        !            71: ?>
        !            72: --EXPECTF--
        !            73: *** Testing symlink(), linkinfo(), link() and is_link() : basic functionality ***
        !            74: 
        !            75: *** Testing symlink(), linkinfo(), link() and is_link() on directory ***
        !            76: 
        !            77: -- Testing on soft links --
        !            78: bool(true)
        !            79: int(%d)
        !            80: bool(true)
        !            81: 
        !            82: -- Testing on hard links --
        !            83: 
        !            84: Warning: link(): %s in %s on line %d
        !            85: bool(false)
        !            86: 
        !            87: Warning: linkinfo(): No such file or directory in %s on line %d
        !            88: int(-1)
        !            89: bool(false)
        !            90: Done

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