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

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

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