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

1.1       misho       1: --TEST--
                      2: Test imap_close() function : usage variations - different ints 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 integers as $options arg to imap_close() to test which are
                     16:  * recognised as CL_EXPUNGE option
                     17:  */
                     18: 
                     19: echo "*** Testing imap_close() : usage variations ***\n";
                     20: 
                     21: require_once(dirname(__FILE__).'/imap_include.inc');
                     22: 
                     23: $inputs = array (0, 3.2768e4, -32768, PHP_INT_MAX, -PHP_INT_MAX);
                     24: 
                     25: $stream_id = setup_test_mailbox('', 3, $mailbox); // set up temp mailbox with 3 messages
                     26: 
                     27: // loop through each element of $inputs to check the behavior of imap_close()
                     28: $iterator = 1;
                     29: foreach($inputs as $input) {
                     30: 
                     31:        // mark added messages for deletion
                     32:        for ($i = 1; $i < 4; $i++) {
                     33:                imap_delete($stream_id, $i);
                     34:        }
                     35:        echo "\n-- Iteration $iterator --\n";
                     36:        var_dump( $check = imap_close($stream_id, $input) );
                     37: 
                     38:        // check that imap_close was successful, if not call imap_close and explicitly set CL_EXPUNGE
                     39:        if(false === $check) {
                     40:                imap_close($stream_id, CL_EXPUNGE);
                     41:        } else {
                     42:                // if imap_close was successful test whether CL_EXPUNGE was set by doing a message count
                     43:                $imap_stream = imap_open($mailbox, $username, $password);
                     44:                $num_msg = imap_num_msg($imap_stream);
                     45:                if ($num_msg != 0) {
                     46:                        echo "CL_EXPUNGE was not set, $num_msg msgs in mailbox\n";
                     47:                } else {
                     48:                        echo "CL_EXPUNGE was set\n";
                     49:                }
                     50:                // call imap_close with CL_EXPUNGE explicitly set in case mailbox not empty
                     51:                imap_close($imap_stream, CL_EXPUNGE);
                     52:        }
                     53:        $iterator++;
                     54: 
                     55:        // get $stream_id for next iteration
                     56:        $stream_id = imap_open($mailbox, $username, $password);
                     57:        populate_mailbox($stream_id, $mailbox, 3);
                     58: 
                     59: };
                     60: ?>
                     61: ===DONE===
                     62: --CLEAN--
                     63: <?php
                     64: require_once(dirname(__FILE__).'/clean.inc');
                     65: ?>
                     66: --EXPECTF--
                     67: *** Testing imap_close() : usage variations ***
                     68: Create a temporary mailbox and add 3 msgs
                     69: .. mailbox '{%s}%s' created
                     70: 
                     71: -- Iteration 1 --
                     72: bool(true)
                     73: CL_EXPUNGE was not set, 3 msgs in mailbox
                     74: 
                     75: -- Iteration 2 --
                     76: bool(true)
                     77: CL_EXPUNGE was set
                     78: 
                     79: -- Iteration 3 --
                     80: 
                     81: Warning: imap_close(): invalid value for the flags parameter in %s on line %d
                     82: bool(false)
                     83: 
                     84: -- Iteration 4 --
                     85: 
                     86: Warning: imap_close(): invalid value for the flags parameter in %s on line %d
                     87: bool(false)
                     88: 
                     89: -- Iteration 5 --
                     90: 
                     91: Warning: imap_close(): invalid value for the flags parameter in %s on line %d
                     92: bool(false)
                     93: ===DONE===

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