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