imap_fetch_overview_variation1.phpt 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. --TEST--
  2. Test imap_fetch_overview() function : usage variations - diff data types as $stream_id arg
  3. --SKIPIF--
  4. <?php
  5. extension_loaded('imap') or die('skip imap extension not available in this build');
  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 $stream_id argument to imap_fetch_overview() to test behaviour
  16. */
  17. echo "*** Testing imap_fetch_overview() : usage variations ***\n";
  18. // Initialise function arguments not being substituted
  19. $msg_no = 1;
  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. // unexpected values to be passed to $stream_id argument
  35. $inputs = array(
  36. // int data
  37. /*1*/ 0,
  38. 1,
  39. 12345,
  40. -2345,
  41. // float data
  42. /*5*/ 10.5,
  43. -10.5,
  44. 12.3456789000e10,
  45. 12.3456789000E-10,
  46. .5,
  47. // null data
  48. /*10*/ NULL,
  49. null,
  50. // boolean data
  51. /*12*/ true,
  52. false,
  53. TRUE,
  54. FALSE,
  55. // empty data
  56. /*16*/ "",
  57. '',
  58. array(),
  59. // string data
  60. /*19*/ "string",
  61. 'string',
  62. $heredoc,
  63. // object data
  64. /*22*/ new classA(),
  65. // undefined data
  66. /*23*/ @$undefined_var,
  67. // unset data
  68. /*24*/ @$unset_var,
  69. );
  70. // loop through each element of $inputs to check the behavior of imap_fetch_overview()
  71. $iterator = 1;
  72. foreach($inputs as $input) {
  73. echo "\n-- Testing with first argument value: ";
  74. var_dump($input);
  75. var_dump( imap_fetch_overview($input, $msg_no) );
  76. $iterator++;
  77. };
  78. ?>
  79. ===DONE===
  80. --EXPECTF--
  81. *** Testing imap_fetch_overview() : usage variations ***
  82. -- Testing with first argument value: int(0)
  83. Warning: imap_fetch_overview() expects parameter 1 to be resource, integer given in %s on line %d
  84. NULL
  85. -- Testing with first argument value: int(1)
  86. Warning: imap_fetch_overview() expects parameter 1 to be resource, integer given in %s on line %d
  87. NULL
  88. -- Testing with first argument value: int(12345)
  89. Warning: imap_fetch_overview() expects parameter 1 to be resource, integer given in %s on line %d
  90. NULL
  91. -- Testing with first argument value: int(-2345)
  92. Warning: imap_fetch_overview() expects parameter 1 to be resource, integer given in %s on line %d
  93. NULL
  94. -- Testing with first argument value: float(10.5)
  95. Warning: imap_fetch_overview() expects parameter 1 to be resource, double given in %s on line %d
  96. NULL
  97. -- Testing with first argument value: float(-10.5)
  98. Warning: imap_fetch_overview() expects parameter 1 to be resource, double given in %s on line %d
  99. NULL
  100. -- Testing with first argument value: float(123456789000)
  101. Warning: imap_fetch_overview() expects parameter 1 to be resource, double given in %s on line %d
  102. NULL
  103. -- Testing with first argument value: float(1.23456789E-9)
  104. Warning: imap_fetch_overview() expects parameter 1 to be resource, double given in %s on line %d
  105. NULL
  106. -- Testing with first argument value: float(0.5)
  107. Warning: imap_fetch_overview() expects parameter 1 to be resource, double given in %s on line %d
  108. NULL
  109. -- Testing with first argument value: NULL
  110. Warning: imap_fetch_overview() expects parameter 1 to be resource, null given in %s on line %d
  111. NULL
  112. -- Testing with first argument value: NULL
  113. Warning: imap_fetch_overview() expects parameter 1 to be resource, null given in %s on line %d
  114. NULL
  115. -- Testing with first argument value: bool(true)
  116. Warning: imap_fetch_overview() expects parameter 1 to be resource, boolean given in %s on line %d
  117. NULL
  118. -- Testing with first argument value: bool(false)
  119. Warning: imap_fetch_overview() expects parameter 1 to be resource, boolean given in %s on line %d
  120. NULL
  121. -- Testing with first argument value: bool(true)
  122. Warning: imap_fetch_overview() expects parameter 1 to be resource, boolean given in %s on line %d
  123. NULL
  124. -- Testing with first argument value: bool(false)
  125. Warning: imap_fetch_overview() expects parameter 1 to be resource, boolean given in %s on line %d
  126. NULL
  127. -- Testing with first argument value: %string|unicode%(0) ""
  128. Warning: imap_fetch_overview() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d
  129. NULL
  130. -- Testing with first argument value: %string|unicode%(0) ""
  131. Warning: imap_fetch_overview() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d
  132. NULL
  133. -- Testing with first argument value: array(0) {
  134. }
  135. Warning: imap_fetch_overview() expects parameter 1 to be resource, array given in %s on line %d
  136. NULL
  137. -- Testing with first argument value: %string|unicode%(6) "string"
  138. Warning: imap_fetch_overview() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d
  139. NULL
  140. -- Testing with first argument value: %string|unicode%(6) "string"
  141. Warning: imap_fetch_overview() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d
  142. NULL
  143. -- Testing with first argument value: %string|unicode%(11) "hello world"
  144. Warning: imap_fetch_overview() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d
  145. NULL
  146. -- Testing with first argument value: object(classA)#1 (0) {
  147. }
  148. Warning: imap_fetch_overview() expects parameter 1 to be resource, object given in %s on line %d
  149. NULL
  150. -- Testing with first argument value: NULL
  151. Warning: imap_fetch_overview() expects parameter 1 to be resource, null given in %s on line %d
  152. NULL
  153. -- Testing with first argument value: NULL
  154. Warning: imap_fetch_overview() expects parameter 1 to be resource, null given in %s on line %d
  155. NULL
  156. ===DONE===