Annotation of embedaddon/php/ext/imap/tests/imap_fetch_overview_variation2.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test imap_fetch_overview() function : usage variations - diff data types as $msg_no arg
                      3: --SKIPIF--
                      4: <?php
                      5: require_once(dirname(__FILE__).'/skipif.inc');
                      6: ?>
                      7: --FILE--
                      8: <?php
                      9: /* Prototype  : array imap_fetch_overview(resource $stream_id, int $msg_no [, int $options])
                     10:  * Description: Read an overview of the information in the headers 
                     11:  * of the given message sequence 
                     12:  * Source code: ext/imap/php_imap.c
                     13:  */
                     14: 
                     15: /*
                     16:  * Pass different data types as $msg_no argument to imap_fetch_overview() to test behaviour
                     17:  */
                     18: 
                     19: echo "*** Testing imap_fetch_overview() : usage variations ***\n";
                     20: require_once(dirname(__FILE__).'/imap_include.inc');
                     21: 
                     22: // Initialise function arguments not being substituted
                     23: $stream_id = setup_test_mailbox('', 1, $mailbox, 'notSimple'); // set up temp mailbox with 1 msg
                     24: 
                     25: //get an unset variable
                     26: $unset_var = 10;
                     27: unset ($unset_var);
                     28: 
                     29: // get a class
                     30: class classA
                     31: {
                     32:   public function __toString() {
                     33:     return "Class A object";
                     34:   }
                     35: }
                     36: 
                     37: // heredoc string
                     38: $heredoc = <<<EOT
                     39: hello world
                     40: EOT;
                     41: 
                     42: // get a resource variable
                     43: $fp = fopen(__FILE__, "r");
                     44: 
                     45: // unexpected values to be passed to <<<ARGUMENT HERE>>> argument
                     46: $inputs = array(
                     47: 
                     48:        // int data
                     49: /*1*/  0,
                     50:        1,
                     51:        12345,
                     52:        -2345,
                     53: 
                     54:        // float data
                     55: /*5*/  10.5,
                     56:        -10.5,
                     57:        12.3456789000e10,
                     58:        12.3456789000E-10,
                     59:        .5,
                     60: 
                     61:        // null data
                     62: /*10*/ NULL,
                     63:        null,
                     64: 
                     65:        // boolean data
                     66: /*12*/ true,
                     67:        false,
                     68:        TRUE,
                     69:        FALSE,
                     70:        
                     71:        // empty data
                     72: /*16*/ "",
                     73:        '',
                     74:        array(),
                     75: 
                     76:        // string data
                     77: /*19*/ "string",
                     78:        'string',
                     79:        $heredoc,
                     80:        
                     81:        // object data
                     82: /*22*/ new classA(),
                     83: 
                     84:        // undefined data
                     85: /*23*/ @$undefined_var,
                     86: 
                     87:        // unset data
                     88: /*24*/ @$unset_var,
                     89: 
                     90:        // resource variable
                     91: /*25*/ $fp
                     92: );
                     93: 
                     94: // loop through each element of $inputs to check the behavior of imap_fetch_overview()
                     95: $iterator = 1;
                     96: foreach($inputs as $input) {
                     97:        echo "\n-- Testing with second argument value: ";
                     98:        var_dump($input);
                     99:        $overview = imap_fetch_overview($stream_id, $input);
                    100:        if (!$overview) {
                    101:                echo imap_last_error() . "\n";
                    102:        } else {
                    103:                displayOverviewFields($overview[0]);
                    104:         }
                    105:        $iterator++;
                    106: };
                    107: 
                    108: fclose($fp);
                    109: 
                    110: // clear the error stack
                    111: imap_errors();
                    112: ?>
                    113: ===DONE===
                    114: --CLEAN--
                    115: <?php
                    116: require_once(dirname(__FILE__).'/clean.inc');
                    117: ?>
                    118: --EXPECTF--
                    119: *** Testing imap_fetch_overview() : usage variations ***
                    120: Create a temporary mailbox and add 1 msgs
                    121: .. mailbox '{%s}%s' created
                    122: 
                    123: -- Testing with second argument value: int(0)
                    124: Sequence out of range
                    125: 
                    126: -- Testing with second argument value: int(1)
                    127: size is %d
                    128: uid is %d
                    129: msgno is 1
                    130: recent is %d
                    131: flagged is 0
                    132: answered is 0
                    133: deleted is 0
                    134: seen is 0
                    135: draft is 0
                    136: udate is OK
                    137: 
                    138: -- Testing with second argument value: int(12345)
                    139: Sequence out of range
                    140: 
                    141: -- Testing with second argument value: int(-2345)
                    142: Syntax error in sequence
                    143: 
                    144: -- Testing with second argument value: float(10.5)
                    145: Sequence out of range
                    146: 
                    147: -- Testing with second argument value: float(-10.5)
                    148: Syntax error in sequence
                    149: 
                    150: -- Testing with second argument value: float(123456789000)
                    151: Sequence out of range
                    152: 
                    153: -- Testing with second argument value: float(1.23456789E-9)
                    154: Sequence syntax error
                    155: 
                    156: -- Testing with second argument value: float(0.5)
                    157: Sequence out of range
                    158: 
                    159: -- Testing with second argument value: NULL
                    160: Sequence out of range
                    161: 
                    162: -- Testing with second argument value: NULL
                    163: Sequence out of range
                    164: 
                    165: -- Testing with second argument value: bool(true)
                    166: size is %d
                    167: uid is %d
                    168: msgno is 1
                    169: recent is %d
                    170: flagged is 0
                    171: answered is 0
                    172: deleted is 0
                    173: seen is 0
                    174: draft is 0
                    175: udate is OK
                    176: 
                    177: -- Testing with second argument value: bool(false)
                    178: Sequence out of range
                    179: 
                    180: -- Testing with second argument value: bool(true)
                    181: size is %d
                    182: uid is %d
                    183: msgno is 1
                    184: recent is %d
                    185: flagged is 0
                    186: answered is 0
                    187: deleted is 0
                    188: seen is 0
                    189: draft is 0
                    190: udate is OK
                    191: 
                    192: -- Testing with second argument value: bool(false)
                    193: Sequence out of range
                    194: 
                    195: -- Testing with second argument value: %string|unicode%(0) ""
                    196: Sequence out of range
                    197: 
                    198: -- Testing with second argument value: %string|unicode%(0) ""
                    199: Sequence out of range
                    200: 
                    201: -- Testing with second argument value: array(0) {
                    202: }
                    203: 
                    204: Warning: imap_fetch_overview() expects parameter 2 to be %binary_string_optional%, array given in %s on line %d
                    205: Sequence out of range
                    206: 
                    207: -- Testing with second argument value: %string|unicode%(6) "string"
                    208: Syntax error in sequence
                    209: 
                    210: -- Testing with second argument value: %string|unicode%(6) "string"
                    211: Syntax error in sequence
                    212: 
                    213: -- Testing with second argument value: %string|unicode%(11) "hello world"
                    214: Syntax error in sequence
                    215: 
                    216: -- Testing with second argument value: object(classA)#1 (0) {
                    217: }
                    218: Syntax error in sequence
                    219: 
                    220: -- Testing with second argument value: NULL
                    221: Syntax error in sequence
                    222: 
                    223: -- Testing with second argument value: NULL
                    224: Syntax error in sequence
                    225: 
                    226: -- Testing with second argument value: resource(%d) of type (stream)
                    227: 
                    228: Warning: imap_fetch_overview() expects parameter 2 to be %binary_string_optional%, resource given in %s on line %d
                    229: Syntax error in sequence
                    230: ===DONE===

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