Annotation of embedaddon/php/ext/spl/tests/SplFileObject_fputcsv_variation10.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: SplFileObject::fputcsv(): Usage variations -- with line without any CSV fields
                      3: --FILE--
                      4: <?php
                      5: 
                      6: /* Testing fputcsv() to write to a file when the field has no CSV format */
                      7: 
                      8: echo "*** Testing fputcsv() : with no CSV format in the field ***\n";
                      9: 
                     10: /* the array is with three elements in it. Each element should be read as 
                     11:    1st element is delimiter, 2nd element is enclosure 
                     12:    and 3rd element is csv fields
                     13: */
                     14: 
                     15: $fields = array( array('water_fruit\n'),
                     16:                 array("water_fruit\n"),
                     17:                 array("")
                     18:          );
                     19: 
                     20: $file_path = dirname(__FILE__);
                     21: $file = "$file_path/fputcsv_variation10.tmp";
                     22: 
                     23: $file_modes = array ("r+", "r+b", "r+t",
                     24:                      "a+", "a+b", "a+t",
                     25:                      "w+", "w+b", "w+t",
                     26:                      "x+", "x+b", "x+t"); 
                     27: 
                     28: $loop_counter = 1;
                     29: foreach ($fields as $field) {
                     30:   for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
                     31:     
                     32:     echo "\n-- file opened in $file_modes[$mode_counter] --\n";  
                     33:     // create the file and add the content with has csv fields
                     34:     if ( strstr($file_modes[$mode_counter], "r") ) {
                     35:       $fo = new SplFileObject($file, 'w');
                     36:     } else {
                     37:       $fo = new SplFileObject($file, $file_modes[$mode_counter]);
                     38:     }
                     39:     $csv_field = $field;
                     40:     
                     41:     // write to a file in csv format
                     42:     var_dump( $fo->fputcsv($csv_field) );
                     43:     
                     44:     // check the file pointer position and eof
                     45:     var_dump( $fo->ftell() );
                     46:     var_dump( $fo->eof() );
                     47:     //close the file
                     48:     unset($fo);
                     49:     
                     50:     // print the file contents 
                     51:     var_dump( file_get_contents($file) );
                     52: 
                     53:     //delete file
                     54:     unlink($file);
                     55:   } //end of mode loop 
                     56: } // end of foreach
                     57: 
                     58: echo "Done\n";
                     59: ?>
                     60: --EXPECTF--
                     61: *** Testing fputcsv() : with no CSV format in the field ***
                     62: 
                     63: -- file opened in r+ --
                     64: int(16)
                     65: int(16)
                     66: bool(false)
                     67: string(16) ""water_fruit\n"
                     68: "
                     69: 
                     70: -- file opened in r+b --
                     71: int(16)
                     72: int(16)
                     73: bool(false)
                     74: string(16) ""water_fruit\n"
                     75: "
                     76: 
                     77: -- file opened in r+t --
                     78: int(16)
                     79: int(16)
                     80: bool(false)
                     81: string(%d) ""water_fruit\n"
                     82: "
                     83: 
                     84: -- file opened in a+ --
                     85: int(16)
                     86: int(16)
                     87: bool(false)
                     88: string(16) ""water_fruit\n"
                     89: "
                     90: 
                     91: -- file opened in a+b --
                     92: int(16)
                     93: int(16)
                     94: bool(false)
                     95: string(16) ""water_fruit\n"
                     96: "
                     97: 
                     98: -- file opened in a+t --
                     99: int(16)
                    100: int(16)
                    101: bool(false)
                    102: string(%d) ""water_fruit\n"
                    103: "
                    104: 
                    105: -- file opened in w+ --
                    106: int(16)
                    107: int(16)
                    108: bool(false)
                    109: string(16) ""water_fruit\n"
                    110: "
                    111: 
                    112: -- file opened in w+b --
                    113: int(16)
                    114: int(16)
                    115: bool(false)
                    116: string(16) ""water_fruit\n"
                    117: "
                    118: 
                    119: -- file opened in w+t --
                    120: int(16)
                    121: int(16)
                    122: bool(false)
                    123: string(%d) ""water_fruit\n"
                    124: "
                    125: 
                    126: -- file opened in x+ --
                    127: int(16)
                    128: int(16)
                    129: bool(false)
                    130: string(16) ""water_fruit\n"
                    131: "
                    132: 
                    133: -- file opened in x+b --
                    134: int(16)
                    135: int(16)
                    136: bool(false)
                    137: string(16) ""water_fruit\n"
                    138: "
                    139: 
                    140: -- file opened in x+t --
                    141: int(16)
                    142: int(16)
                    143: bool(false)
                    144: string(%d) ""water_fruit\n"
                    145: "
                    146: 
                    147: -- file opened in r+ --
                    148: int(15)
                    149: int(15)
                    150: bool(false)
                    151: string(15) ""water_fruit
                    152: "
                    153: "
                    154: 
                    155: -- file opened in r+b --
                    156: int(15)
                    157: int(15)
                    158: bool(false)
                    159: string(15) ""water_fruit
                    160: "
                    161: "
                    162: 
                    163: -- file opened in r+t --
                    164: int(15)
                    165: int(15)
                    166: bool(false)
                    167: string(%d) ""water_fruit
                    168: "
                    169: "
                    170: 
                    171: -- file opened in a+ --
                    172: int(15)
                    173: int(15)
                    174: bool(false)
                    175: string(15) ""water_fruit
                    176: "
                    177: "
                    178: 
                    179: -- file opened in a+b --
                    180: int(15)
                    181: int(15)
                    182: bool(false)
                    183: string(15) ""water_fruit
                    184: "
                    185: "
                    186: 
                    187: -- file opened in a+t --
                    188: int(15)
                    189: int(15)
                    190: bool(false)
                    191: string(%d) ""water_fruit
                    192: "
                    193: "
                    194: 
                    195: -- file opened in w+ --
                    196: int(15)
                    197: int(15)
                    198: bool(false)
                    199: string(15) ""water_fruit
                    200: "
                    201: "
                    202: 
                    203: -- file opened in w+b --
                    204: int(15)
                    205: int(15)
                    206: bool(false)
                    207: string(15) ""water_fruit
                    208: "
                    209: "
                    210: 
                    211: -- file opened in w+t --
                    212: int(15)
                    213: int(15)
                    214: bool(false)
                    215: string(%d) ""water_fruit
                    216: "
                    217: "
                    218: 
                    219: -- file opened in x+ --
                    220: int(15)
                    221: int(15)
                    222: bool(false)
                    223: string(15) ""water_fruit
                    224: "
                    225: "
                    226: 
                    227: -- file opened in x+b --
                    228: int(15)
                    229: int(15)
                    230: bool(false)
                    231: string(15) ""water_fruit
                    232: "
                    233: "
                    234: 
                    235: -- file opened in x+t --
                    236: int(15)
                    237: int(15)
                    238: bool(false)
                    239: string(%d) ""water_fruit
                    240: "
                    241: "
                    242: 
                    243: -- file opened in r+ --
                    244: int(1)
                    245: int(1)
                    246: bool(false)
                    247: string(1) "
                    248: "
                    249: 
                    250: -- file opened in r+b --
                    251: int(1)
                    252: int(1)
                    253: bool(false)
                    254: string(1) "
                    255: "
                    256: 
                    257: -- file opened in r+t --
                    258: int(1)
                    259: int(1)
                    260: bool(false)
                    261: string(%d) "
                    262: "
                    263: 
                    264: -- file opened in a+ --
                    265: int(1)
                    266: int(1)
                    267: bool(false)
                    268: string(1) "
                    269: "
                    270: 
                    271: -- file opened in a+b --
                    272: int(1)
                    273: int(1)
                    274: bool(false)
                    275: string(1) "
                    276: "
                    277: 
                    278: -- file opened in a+t --
                    279: int(1)
                    280: int(1)
                    281: bool(false)
                    282: string(%d) "
                    283: "
                    284: 
                    285: -- file opened in w+ --
                    286: int(1)
                    287: int(1)
                    288: bool(false)
                    289: string(1) "
                    290: "
                    291: 
                    292: -- file opened in w+b --
                    293: int(1)
                    294: int(1)
                    295: bool(false)
                    296: string(1) "
                    297: "
                    298: 
                    299: -- file opened in w+t --
                    300: int(1)
                    301: int(1)
                    302: bool(false)
                    303: string(%d) "
                    304: "
                    305: 
                    306: -- file opened in x+ --
                    307: int(1)
                    308: int(1)
                    309: bool(false)
                    310: string(1) "
                    311: "
                    312: 
                    313: -- file opened in x+b --
                    314: int(1)
                    315: int(1)
                    316: bool(false)
                    317: string(1) "
                    318: "
                    319: 
                    320: -- file opened in x+t --
                    321: int(1)
                    322: int(1)
                    323: bool(false)
                    324: string(%d) "
                    325: "
                    326: Done
                    327: 

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