imap_fetchbody_variation2.phpt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. --TEST--
  2. Test imap_fetchbody() function : usage variation - 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 : string imap_fetchbody(resource $stream_id, int $msg_no, string $section
  10. * [, int $options])
  11. * Description: Get a specific body section
  12. * Source code: ext/imap/php_imap.c
  13. */
  14. /*
  15. * Pass different data types as $msg_no argument to test behaviour of imap_fetchbody()
  16. */
  17. echo "*** Testing imap_fetchbody() : 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); // set up temp mailbox with 1 simple msg
  21. $section = '1';
  22. //get an unset variable
  23. $unset_var = 10;
  24. unset ($unset_var);
  25. // get a class
  26. class classA
  27. {
  28. public function __toString() {
  29. return "Class A object";
  30. }
  31. }
  32. // heredoc string
  33. $heredoc = <<<EOT
  34. hello world
  35. EOT;
  36. // unexpected values to be passed to $msg_no argument
  37. $inputs = array(
  38. // int data
  39. /*1*/ 0,
  40. 1,
  41. 12345,
  42. -2345,
  43. // float data
  44. /*5*/ 10.5,
  45. -10.5,
  46. 12.3456789000e10,
  47. 12.3456789000E-10,
  48. .5,
  49. // null data
  50. /*10*/ NULL,
  51. null,
  52. // boolean data
  53. /*12*/ true,
  54. false,
  55. TRUE,
  56. FALSE,
  57. // empty data
  58. /*16*/ "",
  59. '',
  60. array(),
  61. // string data
  62. /*19*/ "string",
  63. 'string',
  64. $heredoc,
  65. // object data
  66. /*22*/ new classA(),
  67. // undefined data
  68. /*23*/ @$undefined_var,
  69. // unset data
  70. /*24*/ @$unset_var,
  71. );
  72. // loop through each element of $inputs to check the behavior of imap_fetchbody()
  73. $iterator = 1;
  74. foreach($inputs as $input) {
  75. echo "\n-- Iteration $iterator --\n";
  76. var_dump( imap_fetchbody($stream_id, $input, $section) );
  77. $iterator++;
  78. };
  79. ?>
  80. ===DONE===
  81. --CLEAN--
  82. <?php
  83. require_once(dirname(__FILE__).'/clean.inc');
  84. ?>
  85. --EXPECTF--
  86. *** Testing imap_fetchbody() : usage variations ***
  87. Create a temporary mailbox and add 1 msgs
  88. .. mailbox '{%s}%s' created
  89. -- Iteration 1 --
  90. Warning: imap_fetchbody(): Bad message number in %s on line %d
  91. bool(false)
  92. -- Iteration 2 --
  93. %unicode|string%(%d) "1: this is a test message, please ignore%a"
  94. -- Iteration 3 --
  95. Warning: imap_fetchbody(): Bad message number in %s on line %d
  96. bool(false)
  97. -- Iteration 4 --
  98. Warning: imap_fetchbody(): Bad message number in %s on line %d
  99. bool(false)
  100. -- Iteration 5 --
  101. Warning: imap_fetchbody(): Bad message number in %s on line %d
  102. bool(false)
  103. -- Iteration 6 --
  104. Warning: imap_fetchbody(): Bad message number in %s on line %d
  105. bool(false)
  106. -- Iteration 7 --
  107. Warning: imap_fetchbody(): Bad message number in %s on line %d
  108. bool(false)
  109. -- Iteration 8 --
  110. Warning: imap_fetchbody(): Bad message number in %s on line %d
  111. bool(false)
  112. -- Iteration 9 --
  113. Warning: imap_fetchbody(): Bad message number in %s on line %d
  114. bool(false)
  115. -- Iteration 10 --
  116. Warning: imap_fetchbody(): Bad message number in %s on line %d
  117. bool(false)
  118. -- Iteration 11 --
  119. Warning: imap_fetchbody(): Bad message number in %s on line %d
  120. bool(false)
  121. -- Iteration 12 --
  122. %unicode|string%(%d) "1: this is a test message, please ignore%a"
  123. -- Iteration 13 --
  124. Warning: imap_fetchbody(): Bad message number in %s on line %d
  125. bool(false)
  126. -- Iteration 14 --
  127. %unicode|string%(%d) "1: this is a test message, please ignore%a"
  128. -- Iteration 15 --
  129. Warning: imap_fetchbody(): Bad message number in %s on line %d
  130. bool(false)
  131. -- Iteration 16 --
  132. Warning: imap_fetchbody() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
  133. NULL
  134. -- Iteration 17 --
  135. Warning: imap_fetchbody() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
  136. NULL
  137. -- Iteration 18 --
  138. Warning: imap_fetchbody() expects parameter 2 to be long, array given in %s on line %d
  139. NULL
  140. -- Iteration 19 --
  141. Warning: imap_fetchbody() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
  142. NULL
  143. -- Iteration 20 --
  144. Warning: imap_fetchbody() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
  145. NULL
  146. -- Iteration 21 --
  147. Warning: imap_fetchbody() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
  148. NULL
  149. -- Iteration 22 --
  150. Warning: imap_fetchbody() expects parameter 2 to be long, object given in %s on line %d
  151. NULL
  152. -- Iteration 23 --
  153. Warning: imap_fetchbody(): Bad message number in %s on line %d
  154. bool(false)
  155. -- Iteration 24 --
  156. Warning: imap_fetchbody(): Bad message number in %s on line %d
  157. bool(false)
  158. ===DONE===