Annotation of embedaddon/php/ext/standard/tests/file/readlink_realpath_basic2.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test readlink() and realpath functions: basic functionality - diff. path notation for files
! 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: /* creating directories, symbolic links and files */
! 19: $file_path = dirname(__FILE__);
! 20: mkdir("$file_path/readlink_realpath_basic2/home/test/", 0777, true);
! 21:
! 22: $file_handle1 = fopen("$file_path/readlink_realpath_basic2/home/test/readlink_realpath_basic2.tmp", "w");
! 23: $file_handle2 = fopen("$file_path/readlink_realpath_basic2/home/readlink_realpath_basic2.tmp", "w");
! 24: $file_handle3 = fopen("$file_path/readlink_realpath_basic2/readlink_realpath_basic2.tmp", "w");
! 25: fclose($file_handle1);
! 26: fclose($file_handle2);
! 27: fclose($file_handle3);
! 28:
! 29: echo "\n*** Testing realpath() on filenames ***\n";
! 30: $filenames = array (
! 31: /* filenames resulting in valid paths */
! 32: "$file_path/readlink_realpath_basic2/home/readlink_realpath_basic2.tmp",
! 33: "$file_path/readlink_realpath_basic2/readlink_realpath_basic2.tmp",
! 34: "$file_path/readlink_realpath_basic2//home/test//../test/./readlink_realpath_basic2.tmp",
! 35: "$file_path/readlink_realpath_basic2/home//../././readlink_realpath_basic2.tmp",
! 36:
! 37: /* filenames with invalid path */
! 38: "$file_path///readlink_realpath_basic2/home//..//././test//readlink_realpath_basic2.tmp",
! 39: "$file_path/readlink_realpath_basic2/home/../home/../test/../readlink_realpath_basic2.tmp",
! 40: "$file_path/readlink_realpath_basic2/readlink_realpath_basic2.tmp/"
! 41: );
! 42:
! 43: $counter = 1;
! 44: /* loop through $files to read the filepath of $file in the above array */
! 45: foreach($filenames as $file) {
! 46: echo "\n-- Iteration $counter --\n";
! 47: var_dump( realpath($file) );
! 48: $counter++;
! 49: }
! 50:
! 51: echo "Done\n";
! 52: ?>
! 53: --CLEAN--
! 54: <?php
! 55: $name_prefix = dirname(__FILE__)."/readlink_realpath_basic2";
! 56: unlink("$name_prefix/home/test/readlink_realpath_basic2.tmp");
! 57: unlink("$name_prefix/home/readlink_realpath_basic2.tmp");
! 58: unlink("$name_prefix/readlink_realpath_basic2.tmp");
! 59: rmdir("$name_prefix/home/test/");
! 60: rmdir("$name_prefix/home/");
! 61: rmdir("$name_prefix/");
! 62: ?>
! 63: --EXPECTF--
! 64: *** Testing realpath() on filenames ***
! 65:
! 66: -- Iteration 1 --
! 67: string(%d) "%s/readlink_realpath_basic2/home/readlink_realpath_basic2.tmp"
! 68:
! 69: -- Iteration 2 --
! 70: string(%d) "%s/readlink_realpath_basic2/readlink_realpath_basic2.tmp"
! 71:
! 72: -- Iteration 3 --
! 73: string(%d) "%s/readlink_realpath_basic2/home/test/readlink_realpath_basic2.tmp"
! 74:
! 75: -- Iteration 4 --
! 76: string(%d) "%s/readlink_realpath_basic2/readlink_realpath_basic2.tmp"
! 77:
! 78: -- Iteration 5 --
! 79: bool(false)
! 80:
! 81: -- Iteration 6 --
! 82: bool(false)
! 83:
! 84: -- Iteration 7 --
! 85: %s
! 86: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>