imap_fetch_overview_variation2.phpt 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. --TEST--
  2. Test imap_fetch_overview() function : usage variations - 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 : 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. * Pass different data types as $msg_no argument to imap_fetch_overview() to test behaviour
  16. */
  17. echo "*** Testing imap_fetch_overview() : usage variations ***\n";
  18. require_once(dirname(__FILE__).'/imap_include.inc');
  19. // Initialise function arguments not being substituted
  20. $stream_id = setup_test_mailbox('', 1, $mailbox, 'notSimple'); // set up temp mailbox with 1 msg
  21. //get an unset variable
  22. $unset_var = 10;
  23. unset ($unset_var);
  24. // get a class
  25. class classA
  26. {
  27. public function __toString() {
  28. return "Class A object";
  29. }
  30. }
  31. // heredoc string
  32. $heredoc = <<<EOT
  33. hello world
  34. EOT;
  35. // get a resource variable
  36. $fp = fopen(__FILE__, "r");
  37. // unexpected values to be passed to <<<ARGUMENT HERE>>> argument
  38. $inputs = array(
  39. // int data
  40. /*1*/ 0,
  41. 1,
  42. 12345,
  43. -2345,
  44. // float data
  45. /*5*/ 10.5,
  46. -10.5,
  47. 12.3456789000e10,
  48. 12.3456789000E-10,
  49. .5,
  50. // null data
  51. /*10*/ NULL,
  52. null,
  53. // boolean data
  54. /*12*/ true,
  55. false,
  56. TRUE,
  57. FALSE,
  58. // empty data
  59. /*16*/ "",
  60. '',
  61. array(),
  62. // string data
  63. /*19*/ "string",
  64. 'string',
  65. $heredoc,
  66. // object data
  67. /*22*/ new classA(),
  68. // undefined data
  69. /*23*/ @$undefined_var,
  70. // unset data
  71. /*24*/ @$unset_var,
  72. // resource variable
  73. /*25*/ $fp
  74. );
  75. // loop through each element of $inputs to check the behavior of imap_fetch_overview()
  76. $iterator = 1;
  77. foreach($inputs as $input) {
  78. echo "\n-- Testing with second argument value: ";
  79. var_dump($input);
  80. $overview = imap_fetch_overview($stream_id, $input);
  81. if (!$overview) {
  82. echo imap_last_error() . "\n";
  83. } else {
  84. displayOverviewFields($overview[0]);
  85. }
  86. $iterator++;
  87. };
  88. fclose($fp);
  89. // clear the error stack
  90. imap_errors();
  91. ?>
  92. ===DONE===
  93. --CLEAN--
  94. <?php
  95. require_once(dirname(__FILE__).'/clean.inc');
  96. ?>
  97. --EXPECTF--
  98. *** Testing imap_fetch_overview() : usage variations ***
  99. Create a temporary mailbox and add 1 msgs
  100. .. mailbox '{%s}%s' created
  101. -- Testing with second argument value: int(0)
  102. Sequence out of range
  103. -- Testing with second argument value: int(1)
  104. size is %d
  105. uid is %d
  106. msgno is 1
  107. recent is %d
  108. flagged is 0
  109. answered is 0
  110. deleted is 0
  111. seen is 0
  112. draft is 0
  113. udate is OK
  114. -- Testing with second argument value: int(12345)
  115. Sequence out of range
  116. -- Testing with second argument value: int(-2345)
  117. Syntax error in sequence
  118. -- Testing with second argument value: float(10.5)
  119. Sequence out of range
  120. -- Testing with second argument value: float(-10.5)
  121. Syntax error in sequence
  122. -- Testing with second argument value: float(123456789000)
  123. Sequence out of range
  124. -- Testing with second argument value: float(1.23456789E-9)
  125. Sequence syntax error
  126. -- Testing with second argument value: float(0.5)
  127. Sequence out of range
  128. -- Testing with second argument value: NULL
  129. Sequence out of range
  130. -- Testing with second argument value: NULL
  131. Sequence out of range
  132. -- Testing with second argument value: bool(true)
  133. size is %d
  134. uid is %d
  135. msgno is 1
  136. recent is %d
  137. flagged is 0
  138. answered is 0
  139. deleted is 0
  140. seen is 0
  141. draft is 0
  142. udate is OK
  143. -- Testing with second argument value: bool(false)
  144. Sequence out of range
  145. -- Testing with second argument value: bool(true)
  146. size is %d
  147. uid is %d
  148. msgno is 1
  149. recent is %d
  150. flagged is 0
  151. answered is 0
  152. deleted is 0
  153. seen is 0
  154. draft is 0
  155. udate is OK
  156. -- Testing with second argument value: bool(false)
  157. Sequence out of range
  158. -- Testing with second argument value: %string|unicode%(0) ""
  159. Sequence out of range
  160. -- Testing with second argument value: %string|unicode%(0) ""
  161. Sequence out of range
  162. -- Testing with second argument value: array(0) {
  163. }
  164. Warning: imap_fetch_overview() expects parameter 2 to be %binary_string_optional%, array given in %s on line %d
  165. Sequence out of range
  166. -- Testing with second argument value: %string|unicode%(6) "string"
  167. Syntax error in sequence
  168. -- Testing with second argument value: %string|unicode%(6) "string"
  169. Syntax error in sequence
  170. -- Testing with second argument value: %string|unicode%(11) "hello world"
  171. Syntax error in sequence
  172. -- Testing with second argument value: object(classA)#1 (0) {
  173. }
  174. Syntax error in sequence
  175. -- Testing with second argument value: NULL
  176. Syntax error in sequence
  177. -- Testing with second argument value: NULL
  178. Syntax error in sequence
  179. -- Testing with second argument value: resource(%d) of type (stream)
  180. Warning: imap_fetch_overview() expects parameter 2 to be %binary_string_optional%, resource given in %s on line %d
  181. Syntax error in sequence
  182. ===DONE===