Return to is_dir_variation2.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test is_dir() function: usage variations - links 3: --SKIPIF-- 4: <?php 5: if (substr(PHP_OS, 0, 3) == 'WIN') { 6: die('skip Do not run on Windows'); 7: } 8: --FILE-- 9: <?php 10: /* Prototype: bool is_dir ( string $dirname ); 11: Description: Tells whether the dirname is a directory 12: Returns TRUE if the dirname exists and is a directory, FALSE otherwise. 13: */ 14: 15: /* Testing is_dir() with dir, soft & hard link to dir, 16: and with file, soft & hard link to file */ 17: 18: $file_path = dirname(__FILE__); 19: 20: echo "*** Testing is_dir() with dir and links to dir ***\n"; 21: echo "-- With dir --\n"; 22: $dirname = $file_path."/is_dir_variation2"; 23: mkdir($dirname); 24: var_dump( is_dir($dirname) ); 25: clearstatcache(); 26: 27: echo "-- With symlink --\n"; 28: symlink($file_path."/is_dir_variation2", $file_path."/is_dir_variation2_symlink"); 29: var_dump( is_dir($file_path."/is_dir_variation2_symlink") ); //is_dir() resolves symlinks 30: clearstatcache(); 31: 32: echo "-- With hardlink --"; 33: link($file_path."/is_dir_variation2", $file_path."/is_dir_variation2_link"); //Not permitted to create hard-link to a dir 34: var_dump( is_dir($file_path."/is_dir_variation2_link") ); 35: clearstatcache(); 36: 37: echo "\n*** Testing is_dir() with file and links to a file ***\n"; 38: echo "-- With file --\n"; 39: $filename = $file_path."/is_dir_variation2.tmp"; 40: fclose( fopen($filename, "w") ); 41: var_dump( is_dir($filename) ); 42: clearstatcache(); 43: 44: echo "-- With symlink --\n"; 45: symlink($file_path."/is_dir_variation2.tmp", $file_path."/is_dir_variation2_symlink.tmp"); 46: var_dump( is_dir($file_path."/is_dir_variation2_symlink.tmp") ); 47: clearstatcache(); 48: 49: echo "-- With hardlink --\n"; 50: link($file_path."/is_dir_variation2.tmp", $file_path."/is_dir_variation2_link.tmp"); 51: var_dump( is_dir($file_path."/is_dir_variation2_link.tmp") ); 52: clearstatcache(); 53: 54: echo "\n*** Done ***"; 55: ?> 56: --CLEAN-- 57: <?php 58: $file_path = dirname(__FILE__); 59: if(file_exists($file_path."/is_dir_variation2_symlink")) { 60: unlink($file_path."/is_dir_variation2_symlink"); 61: } 62: if(file_exists($file_path."/is_dir_variation2_symlink")) { 63: unlink($file_path."/is_dir_variation2_symlink"); 64: } 65: if(file_exists($file_path."/is_dir_variation2_symlink.tmp")) { 66: unlink($file_path."/is_dir_variation2_symlink.tmp"); 67: } 68: if(file_exists($file_path."/is_dir_variation2_link.tmp")) { 69: unlink($file_path."/is_dir_variation2_link.tmp"); 70: } 71: if(file_exists($file_path."/is_dir_variation2.tmp")) { 72: unlink($file_path."/is_dir_variation2.tmp"); 73: } 74: if(file_exists($file_path."/is_dir_variation2")) { 75: rmdir($file_path."/is_dir_variation2"); 76: } 77: ?> 78: --EXPECTF-- 79: *** Testing is_dir() with dir and links to dir *** 80: -- With dir -- 81: bool(true) 82: -- With symlink -- 83: bool(true) 84: -- With hardlink -- 85: Warning: link(): %s in %s on line %d 86: bool(false) 87: 88: *** Testing is_dir() with file and links to a file *** 89: -- With file -- 90: bool(false) 91: -- With symlink -- 92: bool(false) 93: -- With hardlink -- 94: bool(false) 95: 96: *** Done ***