Return to scandir_variation1-win32.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / dir |
1.1 misho 1: --TEST-- 2: Test scandir() function : usage variations - different data types as $dir arg 3: --SKIPIF-- 4: <?php 5: if (substr(PHP_OS, 0, 3) != 'WIN') { 6: die("skip Valid only on Windows"); 7: } 8: ?> 9: --FILE-- 10: <?php 11: /* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]]) 12: * Description: List files & directories inside the specified path 13: * Source code: ext/standard/dir.c 14: */ 15: 16: /* 17: * Pass different data types as $dir argument to test behaviour of scandir() 18: */ 19: 20: echo "*** Testing scandir() : usage variations ***\n"; 21: 22: //get an unset variable 23: $unset_var = 10; 24: unset ($unset_var); 25: 26: // get a class 27: class classA 28: { 29: public function __toString() { 30: return "Class A object"; 31: } 32: } 33: 34: // heredoc string 35: $heredoc = <<<EOT 36: hello world 37: EOT; 38: 39: // get a resource variable 40: $fp = fopen(__FILE__, "r"); 41: 42: // unexpected values to be passed to $dir argument 43: $inputs = array( 44: 45: // int data 46: /*1*/ 0, 47: 1, 48: 12345, 49: -2345, 50: 51: // float data 52: /*5*/ 10.5, 53: -10.5, 54: 12.3456789000e10, 55: 12.3456789000E-10, 56: .5, 57: 58: // null data 59: /*10*/ NULL, 60: null, 61: 62: // boolean data 63: /*12*/ true, 64: false, 65: TRUE, 66: FALSE, 67: 68: // empty data 69: /*16*/ "", 70: '', 71: array(), 72: 73: // string data 74: /*19*/ "string", 75: 'string', 76: $heredoc, 77: 78: // object data 79: /*22*/ new classA(), 80: 81: // undefined data 82: /*23*/ @$undefined_var, 83: 84: // unset data 85: /*24*/ @$unset_var, 86: 87: // resource variable 88: /*25*/ $fp 89: ); 90: 91: // loop through each element of $inputs to check the behavior of scandir() 92: $iterator = 1; 93: foreach($inputs as $input) { 94: echo "\n-- Iteration $iterator --\n"; 95: var_dump( scandir($input) ); 96: $iterator++; 97: }; 98: 99: fclose($fp); 100: ?> 101: ===DONE=== 102: --EXPECTF-- 103: *** Testing scandir() : usage variations *** 104: 105: -- Iteration 1 -- 106: 107: Warning: scandir(0,0): The system cannot find the file specified. (code: 2) in %s on line %d 108: 109: Warning: scandir(0): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 110: 111: Warning: scandir(): (errno %d): %s in %s on line %d 112: bool(false) 113: 114: -- Iteration 2 -- 115: 116: Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d 117: 118: Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 119: 120: Warning: scandir(): (errno %d): %s in %s on line %d 121: bool(false) 122: 123: -- Iteration 3 -- 124: 125: Warning: scandir(12345,12345): The system cannot find the file specified. (code: 2) in %s on line %d 126: 127: Warning: scandir(12345): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 128: 129: Warning: scandir(): (errno %d): %s in %s on line %d 130: bool(false) 131: 132: -- Iteration 4 -- 133: 134: Warning: scandir(-2345,-2345): The system cannot find the file specified. (code: 2) in %s on line %d 135: 136: Warning: scandir(-2345): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 137: 138: Warning: scandir(): (errno %d): %s in %s on line %d 139: bool(false) 140: 141: -- Iteration 5 -- 142: 143: Warning: scandir(10.5,10.5): The system cannot find the file specified. (code: 2) in %s on line %d 144: 145: Warning: scandir(10.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 146: 147: Warning: scandir(): (errno %d): %s in %s on line %d 148: bool(false) 149: 150: -- Iteration 6 -- 151: 152: Warning: scandir(-10.5,-10.5): The system cannot find the file specified. (code: 2) in %s on line %d 153: 154: Warning: scandir(-10.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 155: 156: Warning: scandir(): (errno %d): %s in %s on line %d 157: bool(false) 158: 159: -- Iteration 7 -- 160: 161: Warning: scandir(123456789000,123456789000): The system cannot find the file specified. (code: 2) in %s on line %d 162: 163: Warning: scandir(123456789000): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 164: 165: Warning: scandir(): (errno %d): %s in %s on line %d 166: bool(false) 167: 168: -- Iteration 8 -- 169: 170: Warning: scandir(1.23456789E-9,1.23456789E-9): The system cannot find the file specified. (code: 2) in %s on line %d 171: 172: Warning: scandir(1.23456789E-9): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 173: 174: Warning: scandir(): (errno %d): %s in %s on line %d 175: bool(false) 176: 177: -- Iteration 9 -- 178: 179: Warning: scandir(0.5,0.5): The system cannot find the file specified. (code: 2) in %s on line %d 180: 181: Warning: scandir(0.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 182: 183: Warning: scandir(): (errno %d): %s in %s on line %d 184: bool(false) 185: 186: -- Iteration 10 -- 187: 188: Warning: scandir(): Directory name cannot be empty in %s on line %d 189: bool(false) 190: 191: -- Iteration 11 -- 192: 193: Warning: scandir(): Directory name cannot be empty in %s on line %d 194: bool(false) 195: 196: -- Iteration 12 -- 197: 198: Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d 199: 200: Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 201: 202: Warning: scandir(): (errno %d): %s in %s on line %d 203: bool(false) 204: 205: -- Iteration 13 -- 206: 207: Warning: scandir(): Directory name cannot be empty in %s on line %d 208: bool(false) 209: 210: -- Iteration 14 -- 211: 212: Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d 213: 214: Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 215: 216: Warning: scandir(): (errno %d): %s in %s on line %d 217: bool(false) 218: 219: -- Iteration 15 -- 220: 221: Warning: scandir(): Directory name cannot be empty in %s on line %d 222: bool(false) 223: 224: -- Iteration 16 -- 225: 226: Warning: scandir(): Directory name cannot be empty in %s on line %d 227: bool(false) 228: 229: -- Iteration 17 -- 230: 231: Warning: scandir(): Directory name cannot be empty in %s on line %d 232: bool(false) 233: 234: -- Iteration 18 -- 235: 236: Warning: scandir() expects parameter 1 to be a valid path, array given in %s on line %d 237: NULL 238: 239: -- Iteration 19 -- 240: 241: Warning: scandir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d 242: 243: Warning: scandir(string): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 244: 245: Warning: scandir(): (errno %d): %s in %s on line %d 246: bool(false) 247: 248: -- Iteration 20 -- 249: 250: Warning: scandir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d 251: 252: Warning: scandir(string): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 253: 254: Warning: scandir(): (errno %d): %s in %s on line %d 255: bool(false) 256: 257: -- Iteration 21 -- 258: 259: Warning: scandir(hello world,hello world): The system cannot find the file specified. (code: 2) in %s on line %d 260: 261: Warning: scandir(hello world): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 262: 263: Warning: scandir(): (errno %d): %s in %s on line %d 264: bool(false) 265: 266: -- Iteration 22 -- 267: 268: Warning: scandir(Class A object,Class A object): The system cannot find the file specified. (code: 2) in %s on line %d 269: 270: Warning: scandir(Class A object): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d 271: 272: Warning: scandir(): (errno %d): %s in %s on line %d 273: bool(false) 274: 275: -- Iteration 23 -- 276: 277: Warning: scandir(): Directory name cannot be empty in %s on line %d 278: bool(false) 279: 280: -- Iteration 24 -- 281: 282: Warning: scandir(): Directory name cannot be empty in %s on line %d 283: bool(false) 284: 285: -- Iteration 25 -- 286: 287: Warning: scandir() expects parameter 1 to be a valid path, resource given in %s on line %d 288: NULL 289: ===DONE===