1--TEST-- 2Test imap_fetchheader() function : usage variations - diff data types as $stream_id arg 3--SKIPIF-- 4<?php 5extension_loaded('imap') or die('skip imap extension not available in this build'); 6?> 7--FILE-- 8<?php 9/* Prototype : string imap_fetchheader(resource $stream_id, int $msg_no [, int $options]) 10 * Description: Get the full unfiltered header for a message 11 * Source code: ext/imap/php_imap.c 12 */ 13 14/* 15 * Pass different data types as $stream_id argument to test behaviour of imap_fetchheader() 16 */ 17 18echo "*** Testing imap_fetchheader() : usage variations ***\n"; 19 20// Initialise function arguments not being substituted 21$msg_no = 1; 22 23//get an unset variable 24$unset_var = 10; 25unset ($unset_var); 26 27// get a class 28class classA 29{ 30 public function __toString() { 31 return "Class A object"; 32 } 33} 34 35// heredoc string 36$heredoc = <<<EOT 37hello world 38EOT; 39 40// get different types of array 41$index_array = array (1, 2, 3); 42$assoc_array = array ('one' => 1, 'two' => 2); 43 44// get a resource variable 45$fp = fopen(__FILE__, "r"); 46 47// unexpected values to be passed to $stream_id argument 48$inputs = array( 49 50 // int data 51/*1*/ 0, 52 1, 53 12345, 54 -2345, 55 56 // float data 57/*5*/ 10.5, 58 -10.5, 59 12.3456789000e10, 60 12.3456789000E-10, 61 .5, 62 63 // null data 64/*10*/ NULL, 65 null, 66 67 // boolean data 68/*12*/ true, 69 false, 70 TRUE, 71 FALSE, 72 73 // empty data 74/*16*/ "", 75 '', 76 77 // string data 78/*18*/ "string", 79 'string', 80 $heredoc, 81 82 // array data 83/*21*/ array(), 84 $index_array, 85 $assoc_array, 86 array('foo', $index_array, $assoc_array), 87 88 89 // object data 90/*25*/ new classA(), 91 92 // undefined data 93/*26*/ @$undefined_var, 94 95 // unset data 96/*27*/ @$unset_var, 97); 98 99// loop through each element of $inputs to check the behavior of imap_fetchheader() 100$iterator = 1; 101foreach($inputs as $input) { 102 echo "\n-- Iteration $iterator --\n"; 103 var_dump( imap_fetchheader($input, $msg_no) ); 104 $iterator++; 105}; 106?> 107===DONE=== 108--EXPECTF-- 109*** Testing imap_fetchheader() : usage variations *** 110 111-- Iteration 1 -- 112 113Warning: imap_fetchheader() expects parameter 1 to be resource, integer given in %s on line %d 114NULL 115 116-- Iteration 2 -- 117 118Warning: imap_fetchheader() expects parameter 1 to be resource, integer given in %s on line %d 119NULL 120 121-- Iteration 3 -- 122 123Warning: imap_fetchheader() expects parameter 1 to be resource, integer given in %s on line %d 124NULL 125 126-- Iteration 4 -- 127 128Warning: imap_fetchheader() expects parameter 1 to be resource, integer given in %s on line %d 129NULL 130 131-- Iteration 5 -- 132 133Warning: imap_fetchheader() expects parameter 1 to be resource, double given in %s on line %d 134NULL 135 136-- Iteration 6 -- 137 138Warning: imap_fetchheader() expects parameter 1 to be resource, double given in %s on line %d 139NULL 140 141-- Iteration 7 -- 142 143Warning: imap_fetchheader() expects parameter 1 to be resource, double given in %s on line %d 144NULL 145 146-- Iteration 8 -- 147 148Warning: imap_fetchheader() expects parameter 1 to be resource, double given in %s on line %d 149NULL 150 151-- Iteration 9 -- 152 153Warning: imap_fetchheader() expects parameter 1 to be resource, double given in %s on line %d 154NULL 155 156-- Iteration 10 -- 157 158Warning: imap_fetchheader() expects parameter 1 to be resource, null given in %s on line %d 159NULL 160 161-- Iteration 11 -- 162 163Warning: imap_fetchheader() expects parameter 1 to be resource, null given in %s on line %d 164NULL 165 166-- Iteration 12 -- 167 168Warning: imap_fetchheader() expects parameter 1 to be resource, boolean given in %s on line %d 169NULL 170 171-- Iteration 13 -- 172 173Warning: imap_fetchheader() expects parameter 1 to be resource, boolean given in %s on line %d 174NULL 175 176-- Iteration 14 -- 177 178Warning: imap_fetchheader() expects parameter 1 to be resource, boolean given in %s on line %d 179NULL 180 181-- Iteration 15 -- 182 183Warning: imap_fetchheader() expects parameter 1 to be resource, boolean given in %s on line %d 184NULL 185 186-- Iteration 16 -- 187 188Warning: imap_fetchheader() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d 189NULL 190 191-- Iteration 17 -- 192 193Warning: imap_fetchheader() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d 194NULL 195 196-- Iteration 18 -- 197 198Warning: imap_fetchheader() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d 199NULL 200 201-- Iteration 19 -- 202 203Warning: imap_fetchheader() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d 204NULL 205 206-- Iteration 20 -- 207 208Warning: imap_fetchheader() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d 209NULL 210 211-- Iteration 21 -- 212 213Warning: imap_fetchheader() expects parameter 1 to be resource, array given in %s on line %d 214NULL 215 216-- Iteration 22 -- 217 218Warning: imap_fetchheader() expects parameter 1 to be resource, array given in %s on line %d 219NULL 220 221-- Iteration 23 -- 222 223Warning: imap_fetchheader() expects parameter 1 to be resource, array given in %s on line %d 224NULL 225 226-- Iteration 24 -- 227 228Warning: imap_fetchheader() expects parameter 1 to be resource, array given in %s on line %d 229NULL 230 231-- Iteration 25 -- 232 233Warning: imap_fetchheader() expects parameter 1 to be resource, object given in %s on line %d 234NULL 235 236-- Iteration 26 -- 237 238Warning: imap_fetchheader() expects parameter 1 to be resource, null given in %s on line %d 239NULL 240 241-- Iteration 27 -- 242 243Warning: imap_fetchheader() expects parameter 1 to be resource, null given in %s on line %d 244NULL 245===DONE=== 246