Return to readfile_basic.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test readfile() function: basic functionality 3: --SKIPIF-- 4: <?php 5: if (substr(PHP_OS, 0, 3) == 'WIN') { 6: die('skip.. only on Linux'); 7: } 8: ?> 9: --FILE-- 10: <?php 11: /* Prototype: int readfile ( string $filename [, bool $use_include_path [, resource $context]] ); 12: Description: Outputs a file 13: */ 14: // common file used 15: require(dirname(__FILE__) . '/file.inc'); 16: 17: echo "*** Testing readfile() : basic functionality ***\n"; 18: $file_path = dirname(__FILE__); 19: $file_prefix = "readfile_basic"; // temp files created with this prefix 20: 21: // the content that is filled into the temp files as created 22: $filetypes = array("numeric", "text", "empty", "alphanumeric", "text_with_new_line"); 23: // different file modes 24: $filemodes = array("w", "wt", "wb", "w+", "w+b", "w+t", 25: "a", "at", "ab", "a+", "a+b", "a+t", 26: "x", "xb", "xt", "x+", "x+b", "x+t"); 27: 28: // create file, read the file content, delete file 29: foreach($filetypes as $type) { 30: echo "\n-- File filled with content type: $type --\n"; 31: foreach($filemodes as $mode) { 32: echo "-- File opened with mode: $mode --\n"; 33: if ( strstr($mode, "x") ) { 34: $fp = fopen($file_path."/".$file_prefix."1.tmp", $mode); 35: fill_file($fp, $type, 100); 36: fclose($fp); 37: } else { 38: // creating file in write mode 39: create_files($file_path, 1, $type, 0755, 100, $mode, $file_prefix, 1, "byte"); 40: } 41: $count = readfile($file_path."/".$file_prefix."1.tmp"); 42: echo "\n"; 43: var_dump($count); 44: // delete files created 45: delete_files($file_path, 1, $file_prefix, 1); 46: } 47: } 48: echo "Done\n"; 49: ?> 50: --EXPECT-- 51: *** Testing readfile() : basic functionality *** 52: 53: -- File filled with content type: numeric -- 54: -- File opened with mode: w -- 55: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 56: int(100) 57: -- File opened with mode: wt -- 58: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 59: int(100) 60: -- File opened with mode: wb -- 61: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 62: int(100) 63: -- File opened with mode: w+ -- 64: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 65: int(100) 66: -- File opened with mode: w+b -- 67: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 68: int(100) 69: -- File opened with mode: w+t -- 70: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 71: int(100) 72: -- File opened with mode: a -- 73: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 74: int(100) 75: -- File opened with mode: at -- 76: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 77: int(100) 78: -- File opened with mode: ab -- 79: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 80: int(100) 81: -- File opened with mode: a+ -- 82: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 83: int(100) 84: -- File opened with mode: a+b -- 85: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 86: int(100) 87: -- File opened with mode: a+t -- 88: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 89: int(100) 90: -- File opened with mode: x -- 91: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 92: int(100) 93: -- File opened with mode: xb -- 94: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 95: int(100) 96: -- File opened with mode: xt -- 97: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 98: int(100) 99: -- File opened with mode: x+ -- 100: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 101: int(100) 102: -- File opened with mode: x+b -- 103: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 104: int(100) 105: -- File opened with mode: x+t -- 106: 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 107: int(100) 108: 109: -- File filled with content type: text -- 110: -- File opened with mode: w -- 111: text text text text text text text text text text text text text text text text text text text text 112: int(100) 113: -- File opened with mode: wt -- 114: text text text text text text text text text text text text text text text text text text text text 115: int(100) 116: -- File opened with mode: wb -- 117: text text text text text text text text text text text text text text text text text text text text 118: int(100) 119: -- File opened with mode: w+ -- 120: text text text text text text text text text text text text text text text text text text text text 121: int(100) 122: -- File opened with mode: w+b -- 123: text text text text text text text text text text text text text text text text text text text text 124: int(100) 125: -- File opened with mode: w+t -- 126: text text text text text text text text text text text text text text text text text text text text 127: int(100) 128: -- File opened with mode: a -- 129: text text text text text text text text text text text text text text text text text text text text 130: int(100) 131: -- File opened with mode: at -- 132: text text text text text text text text text text text text text text text text text text text text 133: int(100) 134: -- File opened with mode: ab -- 135: text text text text text text text text text text text text text text text text text text text text 136: int(100) 137: -- File opened with mode: a+ -- 138: text text text text text text text text text text text text text text text text text text text text 139: int(100) 140: -- File opened with mode: a+b -- 141: text text text text text text text text text text text text text text text text text text text text 142: int(100) 143: -- File opened with mode: a+t -- 144: text text text text text text text text text text text text text text text text text text text text 145: int(100) 146: -- File opened with mode: x -- 147: text text text text text text text text text text text text text text text text text text text text 148: int(100) 149: -- File opened with mode: xb -- 150: text text text text text text text text text text text text text text text text text text text text 151: int(100) 152: -- File opened with mode: xt -- 153: text text text text text text text text text text text text text text text text text text text text 154: int(100) 155: -- File opened with mode: x+ -- 156: text text text text text text text text text text text text text text text text text text text text 157: int(100) 158: -- File opened with mode: x+b -- 159: text text text text text text text text text text text text text text text text text text text text 160: int(100) 161: -- File opened with mode: x+t -- 162: text text text text text text text text text text text text text text text text text text text text 163: int(100) 164: 165: -- File filled with content type: empty -- 166: -- File opened with mode: w -- 167: 168: int(0) 169: -- File opened with mode: wt -- 170: 171: int(0) 172: -- File opened with mode: wb -- 173: 174: int(0) 175: -- File opened with mode: w+ -- 176: 177: int(0) 178: -- File opened with mode: w+b -- 179: 180: int(0) 181: -- File opened with mode: w+t -- 182: 183: int(0) 184: -- File opened with mode: a -- 185: 186: int(0) 187: -- File opened with mode: at -- 188: 189: int(0) 190: -- File opened with mode: ab -- 191: 192: int(0) 193: -- File opened with mode: a+ -- 194: 195: int(0) 196: -- File opened with mode: a+b -- 197: 198: int(0) 199: -- File opened with mode: a+t -- 200: 201: int(0) 202: -- File opened with mode: x -- 203: 204: int(0) 205: -- File opened with mode: xb -- 206: 207: int(0) 208: -- File opened with mode: xt -- 209: 210: int(0) 211: -- File opened with mode: x+ -- 212: 213: int(0) 214: -- File opened with mode: x+b -- 215: 216: int(0) 217: -- File opened with mode: x+t -- 218: 219: int(0) 220: 221: -- File filled with content type: alphanumeric -- 222: -- File opened with mode: w -- 223: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 224: int(100) 225: -- File opened with mode: wt -- 226: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 227: int(100) 228: -- File opened with mode: wb -- 229: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 230: int(100) 231: -- File opened with mode: w+ -- 232: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 233: int(100) 234: -- File opened with mode: w+b -- 235: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 236: int(100) 237: -- File opened with mode: w+t -- 238: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 239: int(100) 240: -- File opened with mode: a -- 241: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 242: int(100) 243: -- File opened with mode: at -- 244: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 245: int(100) 246: -- File opened with mode: ab -- 247: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 248: int(100) 249: -- File opened with mode: a+ -- 250: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 251: int(100) 252: -- File opened with mode: a+b -- 253: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 254: int(100) 255: -- File opened with mode: a+t -- 256: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 257: int(100) 258: -- File opened with mode: x -- 259: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 260: int(100) 261: -- File opened with mode: xb -- 262: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 263: int(100) 264: -- File opened with mode: xt -- 265: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 266: int(100) 267: -- File opened with mode: x+ -- 268: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 269: int(100) 270: -- File opened with mode: x+b -- 271: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 272: int(100) 273: -- File opened with mode: x+t -- 274: ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 275: int(100) 276: 277: -- File filled with content type: text_with_new_line -- 278: -- File opened with mode: w -- 279: line 280: line of text 281: line 282: line of text 283: line 284: line of text 285: line 286: line of text 287: line 288: line of text 289: line 290: line 291: int(100) 292: -- File opened with mode: wt -- 293: line 294: line of text 295: line 296: line of text 297: line 298: line of text 299: line 300: line of text 301: line 302: line of text 303: line 304: line 305: int(100) 306: -- File opened with mode: wb -- 307: line 308: line of text 309: line 310: line of text 311: line 312: line of text 313: line 314: line of text 315: line 316: line of text 317: line 318: line 319: int(100) 320: -- File opened with mode: w+ -- 321: line 322: line of text 323: line 324: line of text 325: line 326: line of text 327: line 328: line of text 329: line 330: line of text 331: line 332: line 333: int(100) 334: -- File opened with mode: w+b -- 335: line 336: line of text 337: line 338: line of text 339: line 340: line of text 341: line 342: line of text 343: line 344: line of text 345: line 346: line 347: int(100) 348: -- File opened with mode: w+t -- 349: line 350: line of text 351: line 352: line of text 353: line 354: line of text 355: line 356: line of text 357: line 358: line of text 359: line 360: line 361: int(100) 362: -- File opened with mode: a -- 363: line 364: line of text 365: line 366: line of text 367: line 368: line of text 369: line 370: line of text 371: line 372: line of text 373: line 374: line 375: int(100) 376: -- File opened with mode: at -- 377: line 378: line of text 379: line 380: line of text 381: line 382: line of text 383: line 384: line of text 385: line 386: line of text 387: line 388: line 389: int(100) 390: -- File opened with mode: ab -- 391: line 392: line of text 393: line 394: line of text 395: line 396: line of text 397: line 398: line of text 399: line 400: line of text 401: line 402: line 403: int(100) 404: -- File opened with mode: a+ -- 405: line 406: line of text 407: line 408: line of text 409: line 410: line of text 411: line 412: line of text 413: line 414: line of text 415: line 416: line 417: int(100) 418: -- File opened with mode: a+b -- 419: line 420: line of text 421: line 422: line of text 423: line 424: line of text 425: line 426: line of text 427: line 428: line of text 429: line 430: line 431: int(100) 432: -- File opened with mode: a+t -- 433: line 434: line of text 435: line 436: line of text 437: line 438: line of text 439: line 440: line of text 441: line 442: line of text 443: line 444: line 445: int(100) 446: -- File opened with mode: x -- 447: line 448: line of text 449: line 450: line of text 451: line 452: line of text 453: line 454: line of text 455: line 456: line of text 457: line 458: line 459: int(100) 460: -- File opened with mode: xb -- 461: line 462: line of text 463: line 464: line of text 465: line 466: line of text 467: line 468: line of text 469: line 470: line of text 471: line 472: line 473: int(100) 474: -- File opened with mode: xt -- 475: line 476: line of text 477: line 478: line of text 479: line 480: line of text 481: line 482: line of text 483: line 484: line of text 485: line 486: line 487: int(100) 488: -- File opened with mode: x+ -- 489: line 490: line of text 491: line 492: line of text 493: line 494: line of text 495: line 496: line of text 497: line 498: line of text 499: line 500: line 501: int(100) 502: -- File opened with mode: x+b -- 503: line 504: line of text 505: line 506: line of text 507: line 508: line of text 509: line 510: line of text 511: line 512: line of text 513: line 514: line 515: int(100) 516: -- File opened with mode: x+t -- 517: line 518: line of text 519: line 520: line of text 521: line 522: line of text 523: line 524: line of text 525: line 526: line of text 527: line 528: line 529: int(100) 530: Done