Annotation of embedaddon/php/ext/standard/tests/file/readlink_realpath_variation1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test readlink() and realpath() functions: usage variation - linkname/filename stored in object(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: $filename = "$name_prefix/readlink_realpath_variation1/home/tests/link/readlink_realpath_variation1.tmp";
! 21: mkdir("$name_prefix/readlink_realpath_variation1/home/tests/link/", 0777, true);
! 22:
! 23: echo "\n*** Testing readlink() and realpath() with linkname stored inside a object ***\n";
! 24: // create a temp file
! 25: $file_handle = fopen($filename, "w");
! 26: fclose($file_handle);
! 27:
! 28: // creating object with members as linkname
! 29: class object_temp {
! 30: public $linkname;
! 31: function object_temp($link) {
! 32: $this->linkname = $link;
! 33: }
! 34: }
! 35: $obj1 = new object_temp("$name_prefix/readlink_realpath_variation1/../././readlink_realpath_variation1/home/readlink_realpath_variation1_link.tmp");
! 36: $obj2 = new object_temp("$name_prefix/readlink_realpath_variation1/home/../..///readlink_realpath_variation1_link.tmp");
! 37:
! 38: echo "\n-- Testing readlink() and realpath() with softlink, linkname stored inside an object --\n";
! 39: // creating the links
! 40: var_dump( symlink($filename, $obj1->linkname) );
! 41: var_dump( readlink($obj1->linkname) );
! 42: var_dump( realpath($obj1->linkname) );
! 43: var_dump( symlink($filename, $obj2->linkname) );
! 44: var_dump( readlink($obj2->linkname) );
! 45: var_dump( realpath($obj2->linkname) );
! 46:
! 47: // deleting the link
! 48: unlink($obj1->linkname);
! 49: unlink($obj2->linkname);
! 50:
! 51: echo "\n-- Testing readlink() and realpath() with hardlink, linkname stored inside an object --\n";
! 52: // creating hard links
! 53: var_dump( link($filename, $obj1->linkname) );
! 54: var_dump( readlink($obj1->linkname) ); // invalid because readlink doesn't work with hardlink
! 55: var_dump( realpath($obj1->linkname) );
! 56: var_dump( link($filename, $obj2->linkname) );
! 57: var_dump( readlink($obj2->linkname) ); // invalid because readlink doesn't work with hardlink
! 58: var_dump( realpath($obj2->linkname) );
! 59:
! 60: // delete the links
! 61: unlink($obj1->linkname);
! 62: unlink($obj2->linkname);
! 63:
! 64: echo "Done\n";
! 65: ?>
! 66: --CLEAN--
! 67: <?php
! 68: $name_prefix = dirname(__FILE__)."/readlink_realpath_variation1";
! 69: unlink("$name_prefix/home/tests/link/readlink_realpath_variation1.tmp");
! 70: rmdir("$name_prefix/home/tests/link/");
! 71: rmdir("$name_prefix/home/tests/");
! 72: rmdir("$name_prefix/home/");
! 73: rmdir("$name_prefix/");
! 74: ?>
! 75: --EXPECTF--
! 76: *** Testing readlink() and realpath() : usage variations ***
! 77:
! 78: *** Testing readlink() and realpath() with linkname stored inside a object ***
! 79:
! 80: -- Testing readlink() and realpath() with softlink, linkname stored inside an object --
! 81: bool(true)
! 82: string(%d) "%s/readlink_realpath_variation1/home/tests/link/readlink_realpath_variation1.tmp"
! 83: string(%d) "%s/readlink_realpath_variation1/home/tests/link/readlink_realpath_variation1.tmp"
! 84: bool(true)
! 85: string(%d) "%s/readlink_realpath_variation1/home/tests/link/readlink_realpath_variation1.tmp"
! 86: string(%d) "%s/readlink_realpath_variation1/home/tests/link/readlink_realpath_variation1.tmp"
! 87:
! 88: -- Testing readlink() and realpath() with hardlink, linkname stored inside an object --
! 89: bool(true)
! 90:
! 91: Warning: readlink(): Invalid argument in %s on line %d
! 92: bool(false)
! 93: string(%d) "%s/readlink_realpath_variation1/home/readlink_realpath_variation1_link.tmp"
! 94: bool(true)
! 95:
! 96: Warning: readlink(): Invalid argument in %s on line %d
! 97: bool(false)
! 98: string(%d) "%s/readlink_realpath_variation1_link.tmp"
! 99: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>