1--TEST-- 2Test imap_fetch_overview() function : usage variations - diff data types as $msg_no arg 3--SKIPIF-- 4<?php 5require_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 19echo "*** Testing imap_fetch_overview() : usage variations ***\n"; 20require_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; 27unset ($unset_var); 28 29// get a class 30class classA 31{ 32 public function __toString() { 33 return "Class A object"; 34 } 35} 36 37// heredoc string 38$heredoc = <<<EOT 39hello world 40EOT; 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; 96foreach($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 108fclose($fp); 109 110// clear the error stack 111imap_errors(); 112?> 113===DONE=== 114--CLEAN-- 115<?php 116require_once(dirname(__FILE__).'/clean.inc'); 117?> 118--EXPECTF-- 119*** Testing imap_fetch_overview() : usage variations *** 120Create a temporary mailbox and add 1 msgs 121.. mailbox '{%s}%s' created 122 123-- Testing with second argument value: int(0) 124Sequence out of range 125 126-- Testing with second argument value: int(1) 127size is %d 128uid is %d 129msgno is 1 130recent is %d 131flagged is 0 132answered is 0 133deleted is 0 134seen is 0 135draft is 0 136udate is OK 137 138-- Testing with second argument value: int(12345) 139Sequence out of range 140 141-- Testing with second argument value: int(-2345) 142Syntax error in sequence 143 144-- Testing with second argument value: float(10.5) 145Sequence out of range 146 147-- Testing with second argument value: float(-10.5) 148Syntax error in sequence 149 150-- Testing with second argument value: float(123456789000) 151Sequence out of range 152 153-- Testing with second argument value: float(1.23456789E-9) 154Sequence syntax error 155 156-- Testing with second argument value: float(0.5) 157Sequence out of range 158 159-- Testing with second argument value: NULL 160Sequence out of range 161 162-- Testing with second argument value: NULL 163Sequence out of range 164 165-- Testing with second argument value: bool(true) 166size is %d 167uid is %d 168msgno is 1 169recent is %d 170flagged is 0 171answered is 0 172deleted is 0 173seen is 0 174draft is 0 175udate is OK 176 177-- Testing with second argument value: bool(false) 178Sequence out of range 179 180-- Testing with second argument value: bool(true) 181size is %d 182uid is %d 183msgno is 1 184recent is %d 185flagged is 0 186answered is 0 187deleted is 0 188seen is 0 189draft is 0 190udate is OK 191 192-- Testing with second argument value: bool(false) 193Sequence out of range 194 195-- Testing with second argument value: string(0) "" 196Sequence out of range 197 198-- Testing with second argument value: string(0) "" 199Sequence out of range 200 201-- Testing with second argument value: array(0) { 202} 203 204Warning: imap_fetch_overview() expects parameter 2 to be string, array given in %s on line %d 205Sequence out of range 206 207-- Testing with second argument value: string(6) "string" 208Syntax error in sequence 209 210-- Testing with second argument value: string(6) "string" 211Syntax error in sequence 212 213-- Testing with second argument value: string(11) "hello world" 214Syntax error in sequence 215 216-- Testing with second argument value: object(classA)#1 (0) { 217} 218Syntax error in sequence 219 220-- Testing with second argument value: NULL 221Syntax error in sequence 222 223-- Testing with second argument value: NULL 224Syntax error in sequence 225 226-- Testing with second argument value: resource(%d) of type (stream) 227 228Warning: imap_fetch_overview() expects parameter 2 to be string, resource given in %s on line %d 229Syntax error in sequence 230===DONE=== 231