Annotation of embedaddon/php/ext/spl/tests/SplFileObject_fputcsv_variation5.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test fputcsv() : usage variations - with default arguments value
! 3: --FILE--
! 4: <?php
! 5:
! 6: /* Testing fputcsv() to write to a file when default arguments values are considered */
! 7:
! 8: echo "*** Testing fputcsv() : with default arguments value ***\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: $csv_lists = array (
! 15: array(',', '"', array('water','fruit') ),
! 16: array(',', '"', array('"water","fruit') ),
! 17: array(',', '"', array('"water","fruit"') ),
! 18: array(' ', '^', array('^water^ ^fruit^')),
! 19: array(':', '&', array('&water&:&fruit&')),
! 20: array('=', '=', array('=water===fruit=')),
! 21: array('-', '-', array('-water--fruit-air')),
! 22: array('-', '-', array('-water---fruit---air-')),
! 23: array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
! 24:
! 25: );
! 26: $file_path = dirname(__FILE__);
! 27: $file = "$file_path/fputcsv_variation5.tmp";
! 28:
! 29: $file_modes = array ("r+", "r+b", "r+t",
! 30: "a+", "a+b", "a+t",
! 31: "w+", "w+b", "w+t",
! 32: "x+", "x+b", "x+t");
! 33:
! 34: $loop_counter = 1;
! 35: foreach ($csv_lists as $csv_list) {
! 36: for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
! 37:
! 38: echo "\n-- file opened in $file_modes[$mode_counter] --\n";
! 39: // create the file and add the content with has csv fields
! 40: if ( strstr($file_modes[$mode_counter], "r") ) {
! 41: $fo = new SplFileObject($file, 'w');
! 42: } else {
! 43: $fo = new SplFileObject($file, $file_modes[$mode_counter]);
! 44: }
! 45: $delimiter = $csv_list[0];
! 46: $enclosure = $csv_list[1];
! 47: $csv_field = $csv_list[2];
! 48:
! 49: // write to a file in csv format
! 50: var_dump( $fo->fputcsv($csv_field) );
! 51: // check the file pointer position and eof
! 52: var_dump( $fo->ftell() );
! 53: var_dump( $fo->eof() );
! 54: //close the file
! 55: unset($fo);
! 56:
! 57: // print the file contents
! 58: var_dump( file_get_contents($file) );
! 59:
! 60: //delete file
! 61: unlink($file);
! 62: } //end of mode loop
! 63: } // end of foreach
! 64:
! 65: echo "Done\n";
! 66: ?>
! 67: --EXPECTF--
! 68: *** Testing fputcsv() : with default arguments value ***
! 69:
! 70: -- file opened in r+ --
! 71: int(12)
! 72: int(12)
! 73: bool(false)
! 74: string(12) "water,fruit
! 75: "
! 76:
! 77: -- file opened in r+b --
! 78: int(12)
! 79: int(12)
! 80: bool(false)
! 81: string(12) "water,fruit
! 82: "
! 83:
! 84: -- file opened in r+t --
! 85: int(12)
! 86: int(12)
! 87: bool(false)
! 88: string(%d) "water,fruit
! 89: "
! 90:
! 91: -- file opened in a+ --
! 92: int(12)
! 93: int(12)
! 94: bool(false)
! 95: string(12) "water,fruit
! 96: "
! 97:
! 98: -- file opened in a+b --
! 99: int(12)
! 100: int(12)
! 101: bool(false)
! 102: string(12) "water,fruit
! 103: "
! 104:
! 105: -- file opened in a+t --
! 106: int(12)
! 107: int(12)
! 108: bool(false)
! 109: string(%d) "water,fruit
! 110: "
! 111:
! 112: -- file opened in w+ --
! 113: int(12)
! 114: int(12)
! 115: bool(false)
! 116: string(12) "water,fruit
! 117: "
! 118:
! 119: -- file opened in w+b --
! 120: int(12)
! 121: int(12)
! 122: bool(false)
! 123: string(12) "water,fruit
! 124: "
! 125:
! 126: -- file opened in w+t --
! 127: int(12)
! 128: int(12)
! 129: bool(false)
! 130: string(%d) "water,fruit
! 131: "
! 132:
! 133: -- file opened in x+ --
! 134: int(12)
! 135: int(12)
! 136: bool(false)
! 137: string(12) "water,fruit
! 138: "
! 139:
! 140: -- file opened in x+b --
! 141: int(12)
! 142: int(12)
! 143: bool(false)
! 144: string(12) "water,fruit
! 145: "
! 146:
! 147: -- file opened in x+t --
! 148: int(12)
! 149: int(12)
! 150: bool(false)
! 151: string(%d) "water,fruit
! 152: "
! 153:
! 154: -- file opened in r+ --
! 155: int(20)
! 156: int(20)
! 157: bool(false)
! 158: string(20) """"water"",""fruit"
! 159: "
! 160:
! 161: -- file opened in r+b --
! 162: int(20)
! 163: int(20)
! 164: bool(false)
! 165: string(20) """"water"",""fruit"
! 166: "
! 167:
! 168: -- file opened in r+t --
! 169: int(20)
! 170: int(20)
! 171: bool(false)
! 172: string(%d) """"water"",""fruit"
! 173: "
! 174:
! 175: -- file opened in a+ --
! 176: int(20)
! 177: int(20)
! 178: bool(false)
! 179: string(20) """"water"",""fruit"
! 180: "
! 181:
! 182: -- file opened in a+b --
! 183: int(20)
! 184: int(20)
! 185: bool(false)
! 186: string(20) """"water"",""fruit"
! 187: "
! 188:
! 189: -- file opened in a+t --
! 190: int(20)
! 191: int(20)
! 192: bool(false)
! 193: string(%d) """"water"",""fruit"
! 194: "
! 195:
! 196: -- file opened in w+ --
! 197: int(20)
! 198: int(20)
! 199: bool(false)
! 200: string(20) """"water"",""fruit"
! 201: "
! 202:
! 203: -- file opened in w+b --
! 204: int(20)
! 205: int(20)
! 206: bool(false)
! 207: string(20) """"water"",""fruit"
! 208: "
! 209:
! 210: -- file opened in w+t --
! 211: int(20)
! 212: int(20)
! 213: bool(false)
! 214: string(%d) """"water"",""fruit"
! 215: "
! 216:
! 217: -- file opened in x+ --
! 218: int(20)
! 219: int(20)
! 220: bool(false)
! 221: string(20) """"water"",""fruit"
! 222: "
! 223:
! 224: -- file opened in x+b --
! 225: int(20)
! 226: int(20)
! 227: bool(false)
! 228: string(20) """"water"",""fruit"
! 229: "
! 230:
! 231: -- file opened in x+t --
! 232: int(20)
! 233: int(20)
! 234: bool(false)
! 235: string(%d) """"water"",""fruit"
! 236: "
! 237:
! 238: -- file opened in r+ --
! 239: int(22)
! 240: int(22)
! 241: bool(false)
! 242: string(22) """"water"",""fruit"""
! 243: "
! 244:
! 245: -- file opened in r+b --
! 246: int(22)
! 247: int(22)
! 248: bool(false)
! 249: string(22) """"water"",""fruit"""
! 250: "
! 251:
! 252: -- file opened in r+t --
! 253: int(22)
! 254: int(22)
! 255: bool(false)
! 256: string(%d) """"water"",""fruit"""
! 257: "
! 258:
! 259: -- file opened in a+ --
! 260: int(22)
! 261: int(22)
! 262: bool(false)
! 263: string(22) """"water"",""fruit"""
! 264: "
! 265:
! 266: -- file opened in a+b --
! 267: int(22)
! 268: int(22)
! 269: bool(false)
! 270: string(22) """"water"",""fruit"""
! 271: "
! 272:
! 273: -- file opened in a+t --
! 274: int(22)
! 275: int(22)
! 276: bool(false)
! 277: string(%d) """"water"",""fruit"""
! 278: "
! 279:
! 280: -- file opened in w+ --
! 281: int(22)
! 282: int(22)
! 283: bool(false)
! 284: string(22) """"water"",""fruit"""
! 285: "
! 286:
! 287: -- file opened in w+b --
! 288: int(22)
! 289: int(22)
! 290: bool(false)
! 291: string(22) """"water"",""fruit"""
! 292: "
! 293:
! 294: -- file opened in w+t --
! 295: int(22)
! 296: int(22)
! 297: bool(false)
! 298: string(%d) """"water"",""fruit"""
! 299: "
! 300:
! 301: -- file opened in x+ --
! 302: int(22)
! 303: int(22)
! 304: bool(false)
! 305: string(22) """"water"",""fruit"""
! 306: "
! 307:
! 308: -- file opened in x+b --
! 309: int(22)
! 310: int(22)
! 311: bool(false)
! 312: string(22) """"water"",""fruit"""
! 313: "
! 314:
! 315: -- file opened in x+t --
! 316: int(22)
! 317: int(22)
! 318: bool(false)
! 319: string(%d) """"water"",""fruit"""
! 320: "
! 321:
! 322: -- file opened in r+ --
! 323: int(18)
! 324: int(18)
! 325: bool(false)
! 326: string(18) ""^water^ ^fruit^"
! 327: "
! 328:
! 329: -- file opened in r+b --
! 330: int(18)
! 331: int(18)
! 332: bool(false)
! 333: string(18) ""^water^ ^fruit^"
! 334: "
! 335:
! 336: -- file opened in r+t --
! 337: int(18)
! 338: int(18)
! 339: bool(false)
! 340: string(%d) ""^water^ ^fruit^"
! 341: "
! 342:
! 343: -- file opened in a+ --
! 344: int(18)
! 345: int(18)
! 346: bool(false)
! 347: string(18) ""^water^ ^fruit^"
! 348: "
! 349:
! 350: -- file opened in a+b --
! 351: int(18)
! 352: int(18)
! 353: bool(false)
! 354: string(18) ""^water^ ^fruit^"
! 355: "
! 356:
! 357: -- file opened in a+t --
! 358: int(18)
! 359: int(18)
! 360: bool(false)
! 361: string(%d) ""^water^ ^fruit^"
! 362: "
! 363:
! 364: -- file opened in w+ --
! 365: int(18)
! 366: int(18)
! 367: bool(false)
! 368: string(18) ""^water^ ^fruit^"
! 369: "
! 370:
! 371: -- file opened in w+b --
! 372: int(18)
! 373: int(18)
! 374: bool(false)
! 375: string(18) ""^water^ ^fruit^"
! 376: "
! 377:
! 378: -- file opened in w+t --
! 379: int(18)
! 380: int(18)
! 381: bool(false)
! 382: string(%d) ""^water^ ^fruit^"
! 383: "
! 384:
! 385: -- file opened in x+ --
! 386: int(18)
! 387: int(18)
! 388: bool(false)
! 389: string(18) ""^water^ ^fruit^"
! 390: "
! 391:
! 392: -- file opened in x+b --
! 393: int(18)
! 394: int(18)
! 395: bool(false)
! 396: string(18) ""^water^ ^fruit^"
! 397: "
! 398:
! 399: -- file opened in x+t --
! 400: int(18)
! 401: int(18)
! 402: bool(false)
! 403: string(%d) ""^water^ ^fruit^"
! 404: "
! 405:
! 406: -- file opened in r+ --
! 407: int(16)
! 408: int(16)
! 409: bool(false)
! 410: string(16) "&water&:&fruit&
! 411: "
! 412:
! 413: -- file opened in r+b --
! 414: int(16)
! 415: int(16)
! 416: bool(false)
! 417: string(16) "&water&:&fruit&
! 418: "
! 419:
! 420: -- file opened in r+t --
! 421: int(16)
! 422: int(16)
! 423: bool(false)
! 424: string(%d) "&water&:&fruit&
! 425: "
! 426:
! 427: -- file opened in a+ --
! 428: int(16)
! 429: int(16)
! 430: bool(false)
! 431: string(16) "&water&:&fruit&
! 432: "
! 433:
! 434: -- file opened in a+b --
! 435: int(16)
! 436: int(16)
! 437: bool(false)
! 438: string(16) "&water&:&fruit&
! 439: "
! 440:
! 441: -- file opened in a+t --
! 442: int(16)
! 443: int(16)
! 444: bool(false)
! 445: string(%d) "&water&:&fruit&
! 446: "
! 447:
! 448: -- file opened in w+ --
! 449: int(16)
! 450: int(16)
! 451: bool(false)
! 452: string(16) "&water&:&fruit&
! 453: "
! 454:
! 455: -- file opened in w+b --
! 456: int(16)
! 457: int(16)
! 458: bool(false)
! 459: string(16) "&water&:&fruit&
! 460: "
! 461:
! 462: -- file opened in w+t --
! 463: int(16)
! 464: int(16)
! 465: bool(false)
! 466: string(%d) "&water&:&fruit&
! 467: "
! 468:
! 469: -- file opened in x+ --
! 470: int(16)
! 471: int(16)
! 472: bool(false)
! 473: string(16) "&water&:&fruit&
! 474: "
! 475:
! 476: -- file opened in x+b --
! 477: int(16)
! 478: int(16)
! 479: bool(false)
! 480: string(16) "&water&:&fruit&
! 481: "
! 482:
! 483: -- file opened in x+t --
! 484: int(16)
! 485: int(16)
! 486: bool(false)
! 487: string(%d) "&water&:&fruit&
! 488: "
! 489:
! 490: -- file opened in r+ --
! 491: int(16)
! 492: int(16)
! 493: bool(false)
! 494: string(16) "=water===fruit=
! 495: "
! 496:
! 497: -- file opened in r+b --
! 498: int(16)
! 499: int(16)
! 500: bool(false)
! 501: string(16) "=water===fruit=
! 502: "
! 503:
! 504: -- file opened in r+t --
! 505: int(16)
! 506: int(16)
! 507: bool(false)
! 508: string(%d) "=water===fruit=
! 509: "
! 510:
! 511: -- file opened in a+ --
! 512: int(16)
! 513: int(16)
! 514: bool(false)
! 515: string(16) "=water===fruit=
! 516: "
! 517:
! 518: -- file opened in a+b --
! 519: int(16)
! 520: int(16)
! 521: bool(false)
! 522: string(16) "=water===fruit=
! 523: "
! 524:
! 525: -- file opened in a+t --
! 526: int(16)
! 527: int(16)
! 528: bool(false)
! 529: string(%d) "=water===fruit=
! 530: "
! 531:
! 532: -- file opened in w+ --
! 533: int(16)
! 534: int(16)
! 535: bool(false)
! 536: string(16) "=water===fruit=
! 537: "
! 538:
! 539: -- file opened in w+b --
! 540: int(16)
! 541: int(16)
! 542: bool(false)
! 543: string(16) "=water===fruit=
! 544: "
! 545:
! 546: -- file opened in w+t --
! 547: int(16)
! 548: int(16)
! 549: bool(false)
! 550: string(%d) "=water===fruit=
! 551: "
! 552:
! 553: -- file opened in x+ --
! 554: int(16)
! 555: int(16)
! 556: bool(false)
! 557: string(16) "=water===fruit=
! 558: "
! 559:
! 560: -- file opened in x+b --
! 561: int(16)
! 562: int(16)
! 563: bool(false)
! 564: string(16) "=water===fruit=
! 565: "
! 566:
! 567: -- file opened in x+t --
! 568: int(16)
! 569: int(16)
! 570: bool(false)
! 571: string(%d) "=water===fruit=
! 572: "
! 573:
! 574: -- file opened in r+ --
! 575: int(18)
! 576: int(18)
! 577: bool(false)
! 578: string(18) "-water--fruit-air
! 579: "
! 580:
! 581: -- file opened in r+b --
! 582: int(18)
! 583: int(18)
! 584: bool(false)
! 585: string(18) "-water--fruit-air
! 586: "
! 587:
! 588: -- file opened in r+t --
! 589: int(18)
! 590: int(18)
! 591: bool(false)
! 592: string(%d) "-water--fruit-air
! 593: "
! 594:
! 595: -- file opened in a+ --
! 596: int(18)
! 597: int(18)
! 598: bool(false)
! 599: string(18) "-water--fruit-air
! 600: "
! 601:
! 602: -- file opened in a+b --
! 603: int(18)
! 604: int(18)
! 605: bool(false)
! 606: string(18) "-water--fruit-air
! 607: "
! 608:
! 609: -- file opened in a+t --
! 610: int(18)
! 611: int(18)
! 612: bool(false)
! 613: string(%d) "-water--fruit-air
! 614: "
! 615:
! 616: -- file opened in w+ --
! 617: int(18)
! 618: int(18)
! 619: bool(false)
! 620: string(18) "-water--fruit-air
! 621: "
! 622:
! 623: -- file opened in w+b --
! 624: int(18)
! 625: int(18)
! 626: bool(false)
! 627: string(18) "-water--fruit-air
! 628: "
! 629:
! 630: -- file opened in w+t --
! 631: int(18)
! 632: int(18)
! 633: bool(false)
! 634: string(%d) "-water--fruit-air
! 635: "
! 636:
! 637: -- file opened in x+ --
! 638: int(18)
! 639: int(18)
! 640: bool(false)
! 641: string(18) "-water--fruit-air
! 642: "
! 643:
! 644: -- file opened in x+b --
! 645: int(18)
! 646: int(18)
! 647: bool(false)
! 648: string(18) "-water--fruit-air
! 649: "
! 650:
! 651: -- file opened in x+t --
! 652: int(18)
! 653: int(18)
! 654: bool(false)
! 655: string(%d) "-water--fruit-air
! 656: "
! 657:
! 658: -- file opened in r+ --
! 659: int(22)
! 660: int(22)
! 661: bool(false)
! 662: string(22) "-water---fruit---air-
! 663: "
! 664:
! 665: -- file opened in r+b --
! 666: int(22)
! 667: int(22)
! 668: bool(false)
! 669: string(22) "-water---fruit---air-
! 670: "
! 671:
! 672: -- file opened in r+t --
! 673: int(22)
! 674: int(22)
! 675: bool(false)
! 676: string(%d) "-water---fruit---air-
! 677: "
! 678:
! 679: -- file opened in a+ --
! 680: int(22)
! 681: int(22)
! 682: bool(false)
! 683: string(22) "-water---fruit---air-
! 684: "
! 685:
! 686: -- file opened in a+b --
! 687: int(22)
! 688: int(22)
! 689: bool(false)
! 690: string(22) "-water---fruit---air-
! 691: "
! 692:
! 693: -- file opened in a+t --
! 694: int(22)
! 695: int(22)
! 696: bool(false)
! 697: string(%d) "-water---fruit---air-
! 698: "
! 699:
! 700: -- file opened in w+ --
! 701: int(22)
! 702: int(22)
! 703: bool(false)
! 704: string(22) "-water---fruit---air-
! 705: "
! 706:
! 707: -- file opened in w+b --
! 708: int(22)
! 709: int(22)
! 710: bool(false)
! 711: string(22) "-water---fruit---air-
! 712: "
! 713:
! 714: -- file opened in w+t --
! 715: int(22)
! 716: int(22)
! 717: bool(false)
! 718: string(%d) "-water---fruit---air-
! 719: "
! 720:
! 721: -- file opened in x+ --
! 722: int(22)
! 723: int(22)
! 724: bool(false)
! 725: string(22) "-water---fruit---air-
! 726: "
! 727:
! 728: -- file opened in x+b --
! 729: int(22)
! 730: int(22)
! 731: bool(false)
! 732: string(22) "-water---fruit---air-
! 733: "
! 734:
! 735: -- file opened in x+t --
! 736: int(22)
! 737: int(22)
! 738: bool(false)
! 739: string(%d) "-water---fruit---air-
! 740: "
! 741:
! 742: -- file opened in r+ --
! 743: int(32)
! 744: int(32)
! 745: bool(false)
! 746: string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
! 747: "
! 748:
! 749: -- file opened in r+b --
! 750: int(32)
! 751: int(32)
! 752: bool(false)
! 753: string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
! 754: "
! 755:
! 756: -- file opened in r+t --
! 757: int(32)
! 758: int(32)
! 759: bool(false)
! 760: string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
! 761: "
! 762:
! 763: -- file opened in a+ --
! 764: int(32)
! 765: int(32)
! 766: bool(false)
! 767: string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
! 768: "
! 769:
! 770: -- file opened in a+b --
! 771: int(32)
! 772: int(32)
! 773: bool(false)
! 774: string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
! 775: "
! 776:
! 777: -- file opened in a+t --
! 778: int(32)
! 779: int(32)
! 780: bool(false)
! 781: string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
! 782: "
! 783:
! 784: -- file opened in w+ --
! 785: int(32)
! 786: int(32)
! 787: bool(false)
! 788: string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
! 789: "
! 790:
! 791: -- file opened in w+b --
! 792: int(32)
! 793: int(32)
! 794: bool(false)
! 795: string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
! 796: "
! 797:
! 798: -- file opened in w+t --
! 799: int(32)
! 800: int(32)
! 801: bool(false)
! 802: string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
! 803: "
! 804:
! 805: -- file opened in x+ --
! 806: int(32)
! 807: int(32)
! 808: bool(false)
! 809: string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
! 810: "
! 811:
! 812: -- file opened in x+b --
! 813: int(32)
! 814: int(32)
! 815: bool(false)
! 816: string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
! 817: "
! 818:
! 819: -- file opened in x+t --
! 820: int(32)
! 821: int(32)
! 822: bool(false)
! 823: string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
! 824: "
! 825: Done
! 826:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>