imap_bodystruct_basic.phpt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. --TEST--
  2. Test imap_bodystruct() function : basic functionality
  3. --SKIPIF--
  4. <?php
  5. require_once(dirname(__FILE__).'/skipif.inc');
  6. ?>
  7. --FILE--
  8. <?php
  9. /* Prototype : object imap_bodystruct ( resource $imap_stream , int $msg_number , string $section )
  10. * Description: Read the structure of a specified body section of a specific message.
  11. * Source code: ext/imap/php_imap.c
  12. */
  13. echo "*** Testing string imap_bodystruct : basic functionality ***\n";
  14. require_once(dirname(__FILE__).'/imap_include.inc');
  15. echo "Create a new mailbox for test and add a multipart msgs\n";
  16. $imap_stream = setup_test_mailbox("", 1, $mailbox, "multipart");
  17. if (!is_resource($imap_stream)) {
  18. exit("TEST FAILED: Unable to create test mailbox\n");
  19. }
  20. echo "\nGet and validate structure of body part 1\n";
  21. $m = imap_bodystruct($imap_stream, 1, "1");
  22. $mandatoryFields = array(
  23. 'ifsubtype',
  24. 'ifdescription',
  25. 'ifid',
  26. 'ifdisposition',
  27. 'ifdparameters',
  28. 'ifparameters',
  29. );
  30. foreach($mandatoryFields as $mf)
  31. {
  32. if(isValid($m->$mf))
  33. {
  34. echo "$mf is 0 or 1\n";
  35. }
  36. else
  37. {
  38. echo "$mf FAIL\n";
  39. }
  40. }
  41. if(is_array($m->parameters))
  42. {
  43. echo "parameters is an array\n";
  44. }
  45. echo "\nTry to get part 4!\n";
  46. var_dump(imap_bodystruct($imap_stream, 1, "4"));
  47. imap_close($imap_stream);
  48. function isValid($param)
  49. {
  50. if(($param == 0) || ($param == 1))
  51. {
  52. $result=true;
  53. }
  54. else
  55. {
  56. $result=false;
  57. }
  58. return $result;
  59. }
  60. ?>
  61. ===Done===
  62. --CLEAN--
  63. <?php
  64. require_once('clean.inc');
  65. ?>
  66. --EXPECTF--
  67. *** Testing string imap_bodystruct : basic functionality ***
  68. Create a new mailbox for test and add a multipart msgs
  69. Create a temporary mailbox and add 1 msgs
  70. .. mailbox '{%s}%s' created
  71. Get and validate structure of body part 1
  72. ifsubtype is 0 or 1
  73. ifdescription is 0 or 1
  74. ifid is 0 or 1
  75. ifdisposition is 0 or 1
  76. ifdparameters is 0 or 1
  77. ifparameters is 0 or 1
  78. parameters is an array
  79. Try to get part 4!
  80. bool(false)
  81. ===Done===