imap_fetchheader_variation2.phpt 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. --TEST--
  2. Test imap_fetchheader() function : usage variations - diff data types for $msg_no arg
  3. --SKIPIF--
  4. <?php
  5. require_once(dirname(__FILE__).'/skipif.inc');
  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. * Pass different data types as $msg_no argument to test behaviour of imap_fetchheader()
  15. */
  16. echo "*** Testing imap_fetchheader() : usage variations ***\n";
  17. require_once(dirname(__FILE__).'/imap_include.inc');
  18. // Initialise function arguments not being substituted
  19. $stream_id = setup_test_mailbox('', 1, $mailbox, 'notSimple'); // set up temp mailbox with 1 msg
  20. //get an unset variable
  21. $unset_var = 10;
  22. unset ($unset_var);
  23. // get a class
  24. class classA
  25. {
  26. public function __toString() {
  27. return "Class A object";
  28. }
  29. }
  30. // heredoc string
  31. $heredoc = <<<EOT
  32. hello world
  33. EOT;
  34. $index_array = array (1, 2, 3);
  35. $assoc_array = array ('one' => 1, 'two' => 2);
  36. // get a resource variable
  37. $fp = fopen(__FILE__, "r");
  38. // unexpected values to be passed to $msg_no argument
  39. $inputs = array(
  40. // int data
  41. /*1*/ 0,
  42. 1,
  43. 12345,
  44. -2345,
  45. // float data
  46. /*5*/ 10.5,
  47. -10.5,
  48. 12.3456789000e10,
  49. 12.3456789000E-10,
  50. .5,
  51. // null data
  52. /*10*/ NULL,
  53. null,
  54. // boolean data
  55. /*12*/ true,
  56. false,
  57. TRUE,
  58. FALSE,
  59. // empty data
  60. /*16*/ "",
  61. '',
  62. // string data
  63. /*18*/ "string",
  64. 'string',
  65. $heredoc,
  66. // array data
  67. /*21*/ array(),
  68. $index_array,
  69. $assoc_array,
  70. array('foo', $index_array, $assoc_array),
  71. // object data
  72. /*25*/ new classA(),
  73. // undefined data
  74. /*26*/ @$undefined_var,
  75. // unset data
  76. /*27*/ @$unset_var,
  77. // resource variable
  78. /*28*/ $fp
  79. );
  80. // loop through each element of $inputs to check the behavior of imap_fetchheader()
  81. $iterator = 1;
  82. foreach($inputs as $input) {
  83. echo "\n-- Iteration $iterator --\n";
  84. var_dump( imap_fetchheader($stream_id, $input) );
  85. $iterator++;
  86. };
  87. fclose($fp);
  88. ?>
  89. ===DONE===
  90. --CLEAN--
  91. <?php
  92. require_once(dirname(__FILE__).'/clean.inc');
  93. ?>
  94. ===DONE===
  95. --EXPECTF--
  96. *** Testing imap_fetchheader() : usage variations ***
  97. Create a temporary mailbox and add 1 msgs
  98. .. mailbox '{%s}%s' created
  99. -- Iteration 1 --
  100. Warning: imap_fetchheader(): Bad message number in %s on line %d
  101. bool(false)
  102. -- Iteration 2 --
  103. %unicode|string%(%d) "From: foo@anywhere.com
  104. Subject: Test msg 1
  105. To: %s
  106. MIME-Version: 1.0
  107. Content-Type: MULTIPART/mixed; BOUNDARY="%s"
  108. "
  109. -- Iteration 3 --
  110. Warning: imap_fetchheader(): Bad message number in %s on line %d
  111. bool(false)
  112. -- Iteration 4 --
  113. Warning: imap_fetchheader(): Bad message number in %s on line %d
  114. bool(false)
  115. -- Iteration 5 --
  116. Warning: imap_fetchheader(): Bad message number in %s on line %d
  117. bool(false)
  118. -- Iteration 6 --
  119. Warning: imap_fetchheader(): Bad message number in %s on line %d
  120. bool(false)
  121. -- Iteration 7 --
  122. Warning: imap_fetchheader(): Bad message number in %s on line %d
  123. bool(false)
  124. -- Iteration 8 --
  125. Warning: imap_fetchheader(): Bad message number in %s on line %d
  126. bool(false)
  127. -- Iteration 9 --
  128. Warning: imap_fetchheader(): Bad message number in %s on line %d
  129. bool(false)
  130. -- Iteration 10 --
  131. Warning: imap_fetchheader(): Bad message number in %s on line %d
  132. bool(false)
  133. -- Iteration 11 --
  134. Warning: imap_fetchheader(): Bad message number in %s on line %d
  135. bool(false)
  136. -- Iteration 12 --
  137. %unicode|string%(%d) "From: foo@anywhere.com
  138. Subject: Test msg 1
  139. To: %s
  140. MIME-Version: 1.0
  141. Content-Type: MULTIPART/mixed; BOUNDARY="%s"
  142. "
  143. -- Iteration 13 --
  144. Warning: imap_fetchheader(): Bad message number in %s on line %d
  145. bool(false)
  146. -- Iteration 14 --
  147. %unicode|string%(%d) "From: foo@anywhere.com
  148. Subject: Test msg 1
  149. To: %s
  150. MIME-Version: 1.0
  151. Content-Type: MULTIPART/mixed; BOUNDARY="%s"
  152. "
  153. -- Iteration 15 --
  154. Warning: imap_fetchheader(): Bad message number in %s on line %d
  155. bool(false)
  156. -- Iteration 16 --
  157. Warning: imap_fetchheader() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
  158. NULL
  159. -- Iteration 17 --
  160. Warning: imap_fetchheader() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
  161. NULL
  162. -- Iteration 18 --
  163. Warning: imap_fetchheader() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
  164. NULL
  165. -- Iteration 19 --
  166. Warning: imap_fetchheader() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
  167. NULL
  168. -- Iteration 20 --
  169. Warning: imap_fetchheader() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
  170. NULL
  171. -- Iteration 21 --
  172. Warning: imap_fetchheader() expects parameter 2 to be long, array given in %s on line %d
  173. NULL
  174. -- Iteration 22 --
  175. Warning: imap_fetchheader() expects parameter 2 to be long, array given in %s on line %d
  176. NULL
  177. -- Iteration 23 --
  178. Warning: imap_fetchheader() expects parameter 2 to be long, array given in %s on line %d
  179. NULL
  180. -- Iteration 24 --
  181. Warning: imap_fetchheader() expects parameter 2 to be long, array given in %s on line %d
  182. NULL
  183. -- Iteration 25 --
  184. Warning: imap_fetchheader() expects parameter 2 to be long, object given in %s on line %d
  185. NULL
  186. -- Iteration 26 --
  187. Warning: imap_fetchheader(): Bad message number in %s on line %d
  188. bool(false)
  189. -- Iteration 27 --
  190. Warning: imap_fetchheader(): Bad message number in %s on line %d
  191. bool(false)
  192. -- Iteration 28 --
  193. Warning: imap_fetchheader() expects parameter 2 to be long, resource given in %s on line %d
  194. NULL
  195. ===DONE===