Annotation of embedaddon/php/ext/standard/tests/dir/dir_variation9.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test dir() function : usage variations - relative valid and invalid paths
! 3: --FILE--
! 4: <?php
! 5: /*
! 6: * Prototype : object dir(string $directory[, resource $context])
! 7: * Description: Directory class with properties, handle and class and methods read, rewind and close
! 8: * Source code: ext/standard/dir.c
! 9: */
! 10:
! 11: /*
! 12: * Checking the behavior of dir() function by passing directories which
! 13: * have valid and invalid relative path.
! 14: */
! 15:
! 16: echo "*** Testing dir() : checking with valid and invalid paths ***\n";
! 17:
! 18: /* create the temporary directories */
! 19:
! 20: $file_path = dirname(__FILE__);
! 21:
! 22: // directory dir_variation91 with one sub-directory sub_dir11 and sub-sub-directory sub_dir111
! 23: $dir_path1 = $file_path."/dir_variation91";
! 24: $sub_dir11 = $dir_path1."/sub_dir11";
! 25: $sub_dir111 = $sub_dir11."/sub_dir111";
! 26:
! 27: // directory dir_variation92 with one sub-directory sub_dir21
! 28: $dir_path2 = $file_path."/dir_variation92";
! 29: $sub_dir21 = $dir_path2."/sub_dir21";
! 30:
! 31: @mkdir($dir_path1);
! 32: @mkdir($dir_path2);
! 33: @mkdir($sub_dir11);
! 34: @mkdir($sub_dir111);
! 35: @mkdir($sub_dir21);
! 36:
! 37: // open the directory with valid paths
! 38: echo "\n-- With valid paths --\n";
! 39: var_dump( dir("$dir_path1/sub_dir11/sub_dir111/..") );
! 40: var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91") );
! 41: var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91/sub_dir11/..") );
! 42: var_dump( dir("$dir_path1/sub_dir11/sub_dir111/../../../dir_variation92/sub_dir21/..") );
! 43:
! 44: // open the directory with invalid path
! 45: echo "\n-- With invalid paths --\n";
! 46: var_dump( dir("$dir_path1/sub_dir12/sub_dir111/..") );
! 47: var_dump( dir("$dir_path2/sub_dir21/../dir_variation91") );
! 48: var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91/sub_dir12/..") );
! 49: var_dump( dir("$dir_path1/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..") );
! 50:
! 51: echo "Done";
! 52: ?>
! 53: --CLEAN--
! 54: <?php
! 55: $file_path = dirname(__FILE__);
! 56:
! 57: $dir_path1 = $file_path."/dir_variation91";
! 58: $sub_dir11 = $dir_path1."/sub_dir11";
! 59: $sub_dir111 = $sub_dir11."/sub_dir111";
! 60: $dir_path2 = $file_path."/dir_variation92";
! 61: $sub_dir21 = $dir_path2."/sub_dir21";
! 62:
! 63: rmdir($sub_dir21);
! 64: rmdir($sub_dir111);
! 65: rmdir($sub_dir11);
! 66: rmdir($dir_path1);
! 67: rmdir($dir_path2);
! 68: ?>
! 69: --EXPECTF--
! 70: *** Testing dir() : checking with valid and invalid paths ***
! 71:
! 72: -- With valid paths --
! 73: object(Directory)#%d (2) {
! 74: ["path"]=>
! 75: string(%d) "%s/dir_variation91/sub_dir11/sub_dir111/.."
! 76: ["handle"]=>
! 77: resource(%d) of type (stream)
! 78: }
! 79: object(Directory)#%d (2) {
! 80: ["path"]=>
! 81: string(%d) "%s/dir_variation92/sub_dir21/../../dir_variation91"
! 82: ["handle"]=>
! 83: resource(%d) of type (stream)
! 84: }
! 85: object(Directory)#%d (2) {
! 86: ["path"]=>
! 87: string(%d) "%s/dir_variation92/sub_dir21/../../dir_variation91/sub_dir11/.."
! 88: ["handle"]=>
! 89: resource(%d) of type (stream)
! 90: }
! 91: object(Directory)#%d (2) {
! 92: ["path"]=>
! 93: string(%d) "%s/dir_variation91/sub_dir11/sub_dir111/../../../dir_variation92/sub_dir21/.."
! 94: ["handle"]=>
! 95: resource(%d) of type (stream)
! 96: }
! 97:
! 98: -- With invalid paths --
! 99:
! 100: Warning: dir(%s/dir_variation91/sub_dir12/sub_dir111/..): failed to open dir: %s in %s on line %d
! 101: bool(false)
! 102:
! 103: Warning: dir(%s/dir_variation92/sub_dir21/../dir_variation91): failed to open dir: %s in %s on line %d
! 104: bool(false)
! 105:
! 106: Warning: dir(%s/dir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..): failed to open dir: %s in %s on line %d
! 107: bool(false)
! 108:
! 109: Warning: dir(%s/dir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..): failed to open dir: %s in %s on line %d
! 110: bool(false)
! 111: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>