Annotation of embedaddon/php/ext/standard/tests/file/fflush_variation1.phpt, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>