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

1.1       misho       1: --TEST--
                      2: Test imap_close() function : usage variations - different data types as $options arg
                      3: --SKIPIF--
                      4: <?php
                      5: require_once(dirname(__FILE__).'/skipif.inc');
                      6: ?>
                      7: --FILE--
                      8: <?php
                      9: /* Prototype  : bool imap_close(resource $stream_id [, int $options])
                     10:  * Description: Close an IMAP stream 
                     11:  * Source code: ext/imap/php_imap.c
                     12:  */
                     13: 
                     14: /*
                     15:  * Pass different data types as $options argument to test behaviour of imap_close()
                     16:  */
                     17: 
                     18: echo "*** Testing imap_close() : usage variations ***\n";
                     19: 
                     20: // include file for imap_stream
                     21: require_once(dirname(__FILE__).'/imap_include.inc');
                     22: 
                     23: // create mailbox to test whether options has been set to CL_EXPUNGE
                     24: $stream_id = setup_test_mailbox('', 3, $mailbox);
                     25: 
                     26: //get an unset variable
                     27: $unset_var = 10;
                     28: unset ($unset_var);
                     29: 
                     30: // heredoc string
                     31: $heredoc = <<<EOT
                     32: 32768
                     33: EOT;
                     34: 
                     35: // unexpected values to be passed to $options argument
                     36: $inputs = array(
                     37: 
                     38:        // int data
                     39: /*1*/  0,
                     40:        1,
                     41:        32768,
                     42:        -2345,
                     43: 
                     44:        // float data
                     45: /*5*/  10.5,
                     46:        -10.5,
                     47:        12.3456789000e10,
                     48:        12.3456789000E-10,
                     49:        .5,
                     50: 
                     51:        // null data
                     52: /*10*/ NULL,
                     53:        null,
                     54: 
                     55:        // boolean data
                     56: /*12*/ true,
                     57:        false,
                     58:        TRUE,
                     59:        FALSE,
                     60:        
                     61:        // empty data
                     62: /*16*/ "",
                     63:        '',
                     64:        array(),
                     65: 
                     66:        // string data
                     67: /*19*/ "32768",
                     68:        '32768',
                     69:        $heredoc,
                     70: 
                     71:        // undefined data
                     72: /*22*/ @$undefined_var,
                     73: 
                     74:        // unset data
                     75: /*23*/ @$unset_var,
                     76: );
                     77: 
                     78: // loop through each element of $inputs to check the behavior of imap_close()
                     79: $iterator = 1;
                     80: foreach($inputs as $input) {
                     81: 
                     82:        // mark added messages for deletion
                     83:        for ($i = 1; $i < 4; $i++) {
                     84:                imap_delete($stream_id, $i);
                     85:        }
                     86:        echo "\n-- Iteration $iterator --\n";
                     87:        var_dump( $check = imap_close($stream_id, $input) );
                     88: 
                     89:        // check that imap_close was successful, if not call imap_close and explicitly set CL_EXPUNGE
                     90:        if(false === $check) {
                     91:                imap_close($stream_id, CL_EXPUNGE);
                     92:        } else {
                     93:                // if imap_close was successful test whether CL_EXPUNGE was set by doing a message count
                     94:                $imap_stream = imap_open($mailbox, $username, $password);
                     95:                $num_msg = imap_num_msg($imap_stream);
                     96:                if ($num_msg != 0) {
                     97:                        echo "CL_EXPUNGE was not set, $num_msg msgs in mailbox\n";
                     98:                } else {
                     99:                        echo "CL_EXPUNGE was set\n";
                    100:                }
                    101:                // call imap_close with CL_EXPUNGE explicitly set in case mailbox not empty
                    102:                imap_close($imap_stream, CL_EXPUNGE);
                    103:        }
                    104:        $iterator++;
                    105: 
                    106:        // get $stream_id for next iteration
                    107:        $stream_id = imap_open($mailbox, $username, $password);
                    108:        populate_mailbox($stream_id, $mailbox, 3);
                    109: 
                    110: };
                    111: 
                    112: ?>
                    113: ===DONE===
                    114: --CLEAN--
                    115: <?php
                    116: require_once(dirname(__FILE__).'/clean.inc');
                    117: ?>
                    118: --EXPECTF--
                    119: *** Testing imap_close() : usage variations ***
                    120: Create a temporary mailbox and add 3 msgs
                    121: .. mailbox '{%s}%s' created
                    122: 
                    123: -- Iteration 1 --
                    124: bool(true)
                    125: CL_EXPUNGE was not set, 3 msgs in mailbox
                    126: 
                    127: -- Iteration 2 --
                    128: 
                    129: Warning: imap_close(): invalid value for the flags parameter in %s on line %d
                    130: bool(false)
                    131: 
                    132: -- Iteration 3 --
                    133: bool(true)
                    134: CL_EXPUNGE was set
                    135: 
                    136: -- Iteration 4 --
                    137: 
                    138: Warning: imap_close(): invalid value for the flags parameter in %s on line %d
                    139: bool(false)
                    140: 
                    141: -- Iteration 5 --
                    142: 
                    143: Warning: imap_close(): invalid value for the flags parameter in %s on line %d
                    144: bool(false)
                    145: 
                    146: -- Iteration 6 --
                    147: 
                    148: Warning: imap_close(): invalid value for the flags parameter in %s on line %d
                    149: bool(false)
                    150: 
                    151: -- Iteration 7 --
                    152: 
                    153: Warning: imap_close(): invalid value for the flags parameter in %s on line %d
                    154: bool(false)
                    155: 
                    156: -- Iteration 8 --
                    157: bool(true)
                    158: CL_EXPUNGE was not set, 3 msgs in mailbox
                    159: 
                    160: -- Iteration 9 --
                    161: bool(true)
                    162: CL_EXPUNGE was not set, 3 msgs in mailbox
                    163: 
                    164: -- Iteration 10 --
                    165: bool(true)
                    166: CL_EXPUNGE was not set, 3 msgs in mailbox
                    167: 
                    168: -- Iteration 11 --
                    169: bool(true)
                    170: CL_EXPUNGE was not set, 3 msgs in mailbox
                    171: 
                    172: -- Iteration 12 --
                    173: 
                    174: Warning: imap_close(): invalid value for the flags parameter in %s on line %d
                    175: bool(false)
                    176: 
                    177: -- Iteration 13 --
                    178: bool(true)
                    179: CL_EXPUNGE was not set, 3 msgs in mailbox
                    180: 
                    181: -- Iteration 14 --
                    182: 
                    183: Warning: imap_close(): invalid value for the flags parameter in %s on line %d
                    184: bool(false)
                    185: 
                    186: -- Iteration 15 --
                    187: bool(true)
                    188: CL_EXPUNGE was not set, 3 msgs in mailbox
                    189: 
                    190: -- Iteration 16 --
                    191: 
                    192: Warning: imap_close() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
                    193: NULL
                    194: CL_EXPUNGE was not set, 3 msgs in mailbox
                    195: 
                    196: -- Iteration 17 --
                    197: 
                    198: Warning: imap_close() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
                    199: NULL
                    200: CL_EXPUNGE was not set, 3 msgs in mailbox
                    201: 
                    202: -- Iteration 18 --
                    203: 
                    204: Warning: imap_close() expects parameter 2 to be long, array given in %s on line %d
                    205: NULL
                    206: CL_EXPUNGE was not set, 3 msgs in mailbox
                    207: 
                    208: -- Iteration 19 --
                    209: bool(true)
                    210: CL_EXPUNGE was set
                    211: 
                    212: -- Iteration 20 --
                    213: bool(true)
                    214: CL_EXPUNGE was set
                    215: 
                    216: -- Iteration 21 --
                    217: bool(true)
                    218: CL_EXPUNGE was set
                    219: 
                    220: -- Iteration 22 --
                    221: bool(true)
                    222: CL_EXPUNGE was not set, 3 msgs in mailbox
                    223: 
                    224: -- Iteration 23 --
                    225: bool(true)
                    226: CL_EXPUNGE was not set, 3 msgs in mailbox
                    227: ===DONE===

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