1--TEST-- 2Test imap_bodystruct() function : basic functionality 3--EXTENSIONS-- 4imap 5--SKIPIF-- 6<?php 7require_once(__DIR__.'/setup/skipif.inc'); 8?> 9--FILE-- 10<?php 11echo "*** Testing string imap_bodystruct : basic functionality ***\n"; 12require_once(__DIR__.'/setup/imap_include.inc'); 13 14echo "Create a new mailbox for test and add a multipart msgs\n"; 15$imap_stream = setup_test_mailbox("imapbodystructbasic", 1, $mailbox, "multipart"); 16 17echo "\nGet and validate structure of body part 1\n"; 18 19$m = imap_bodystruct($imap_stream, 1, "1"); 20 21$mandatoryFields = [ 22 'ifsubtype', 23 'ifdescription', 24 'ifid', 25 'ifdisposition', 26 'ifdparameters', 27 'ifparameters', 28]; 29 30function isValid($param) { 31 return ($param == 0) || ($param == 1); 32} 33 34foreach($mandatoryFields as $mf) { 35 if (isValid($m->$mf)) { 36 echo "$mf is 0 or 1\n"; 37 } else { 38 echo "$mf FAIL\n"; 39 } 40} 41 42if(is_array($m->parameters)) { 43 echo "parameters is an array\n"; 44} 45 46echo "\nTry to get part 4!\n"; 47var_dump(imap_bodystruct($imap_stream, 1, "4")); 48 49imap_close($imap_stream); 50 51?> 52--CLEAN-- 53<?php 54$mailbox_suffix = 'imapbodystructbasic'; 55require_once(__DIR__ . '/setup/clean.inc'); 56?> 57--EXPECT-- 58*** Testing string imap_bodystruct : basic functionality *** 59Create a new mailbox for test and add a multipart msgs 60Create a temporary mailbox and add 1 msgs 61New mailbox created 62 63Get and validate structure of body part 1 64ifsubtype is 0 or 1 65ifdescription is 0 or 1 66ifid is 0 or 1 67ifdisposition is 0 or 1 68ifdparameters is 0 or 1 69ifparameters is 0 or 1 70parameters is an array 71 72Try to get part 4! 73bool(false) 74