Annotation of embedaddon/php/ext/imap/tests/imap_fetchbody_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test imap_fetchbody() function : usage variation - 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 : 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 $msg_no 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: $section = '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 $msg_no 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, $input, $section) );
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}%s' created
107:
108: -- Iteration 1 --
109:
110: Warning: imap_fetchbody(): Bad message number in %s on line %d
111: bool(false)
112:
113: -- Iteration 2 --
114: %unicode|string%(%d) "1: this is a test message, please ignore%a"
115:
116: -- Iteration 3 --
117:
118: Warning: imap_fetchbody(): Bad message number in %s on line %d
119: bool(false)
120:
121: -- Iteration 4 --
122:
123: Warning: imap_fetchbody(): Bad message number in %s on line %d
124: bool(false)
125:
126: -- Iteration 5 --
127:
128: Warning: imap_fetchbody(): Bad message number in %s on line %d
129: bool(false)
130:
131: -- Iteration 6 --
132:
133: Warning: imap_fetchbody(): Bad message number in %s on line %d
134: bool(false)
135:
136: -- Iteration 7 --
137:
138: Warning: imap_fetchbody(): Bad message number in %s on line %d
139: bool(false)
140:
141: -- Iteration 8 --
142:
143: Warning: imap_fetchbody(): Bad message number in %s on line %d
144: bool(false)
145:
146: -- Iteration 9 --
147:
148: Warning: imap_fetchbody(): Bad message number in %s on line %d
149: bool(false)
150:
151: -- Iteration 10 --
152:
153: Warning: imap_fetchbody(): Bad message number in %s on line %d
154: bool(false)
155:
156: -- Iteration 11 --
157:
158: Warning: imap_fetchbody(): Bad message number in %s on line %d
159: bool(false)
160:
161: -- Iteration 12 --
162: %unicode|string%(%d) "1: this is a test message, please ignore%a"
163:
164: -- Iteration 13 --
165:
166: Warning: imap_fetchbody(): Bad message number in %s on line %d
167: bool(false)
168:
169: -- Iteration 14 --
170: %unicode|string%(%d) "1: this is a test message, please ignore%a"
171:
172: -- Iteration 15 --
173:
174: Warning: imap_fetchbody(): Bad message number in %s on line %d
175: bool(false)
176:
177: -- Iteration 16 --
178:
179: Warning: imap_fetchbody() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
180: NULL
181:
182: -- Iteration 17 --
183:
184: Warning: imap_fetchbody() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
185: NULL
186:
187: -- Iteration 18 --
188:
189: Warning: imap_fetchbody() expects parameter 2 to be long, array given in %s on line %d
190: NULL
191:
192: -- Iteration 19 --
193:
194: Warning: imap_fetchbody() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
195: NULL
196:
197: -- Iteration 20 --
198:
199: Warning: imap_fetchbody() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
200: NULL
201:
202: -- Iteration 21 --
203:
204: Warning: imap_fetchbody() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
205: NULL
206:
207: -- Iteration 22 --
208:
209: Warning: imap_fetchbody() expects parameter 2 to be long, object given in %s on line %d
210: NULL
211:
212: -- Iteration 23 --
213:
214: Warning: imap_fetchbody(): Bad message number in %s on line %d
215: bool(false)
216:
217: -- Iteration 24 --
218:
219: Warning: imap_fetchbody(): Bad message number in %s on line %d
220: bool(false)
221: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>