1--TEST-- 2Test imap_bodystruct() function : basic functionality 3--SKIPIF-- 4<?php 5require_once(__DIR__.'/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 14echo "*** Testing string imap_bodystruct : basic functionality ***\n"; 15require_once(__DIR__.'/imap_include.inc'); 16 17echo "Create a new mailbox for test and add a multipart msgs\n"; 18$imap_stream = setup_test_mailbox("", 1, $mailbox, "multipart"); 19if (!is_resource($imap_stream)) { 20 exit("TEST FAILED: Unable to create test mailbox\n"); 21} 22 23echo "\nGet and validate structure of body part 1\n"; 24 25$m = imap_bodystruct($imap_stream, 1, "1"); 26 27$mandatoryFields = array( 28 'ifsubtype', 29 'ifdescription', 30 'ifid', 31 'ifdisposition', 32 'ifdparameters', 33 'ifparameters', 34 ); 35 36foreach($mandatoryFields as $mf) 37{ 38 if(isValid($m->$mf)) 39 { 40 echo "$mf is 0 or 1\n"; 41 } 42 else 43 { 44 echo "$mf FAIL\n"; 45 } 46} 47 48if(is_array($m->parameters)) 49{ 50 echo "parameters is an array\n"; 51} 52 53echo "\nTry to get part 4!\n"; 54var_dump(imap_bodystruct($imap_stream, 1, "4")); 55 56imap_close($imap_stream); 57 58function isValid($param) 59{ 60 if(($param == 0) || ($param == 1)) 61 { 62 $result=true; 63 } 64 else 65 { 66 $result=false; 67 } 68return $result; 69} 70?> 71===Done=== 72--CLEAN-- 73<?php 74require_once('clean.inc'); 75?> 76--EXPECTF-- 77*** Testing string imap_bodystruct : basic functionality *** 78Create a new mailbox for test and add a multipart msgs 79Create a temporary mailbox and add 1 msgs 80.. mailbox '{%s}%s' created 81 82Get and validate structure of body part 1 83ifsubtype is 0 or 1 84ifdescription is 0 or 1 85ifid is 0 or 1 86ifdisposition is 0 or 1 87ifdparameters is 0 or 1 88ifparameters is 0 or 1 89parameters is an array 90 91Try to get part 4! 92bool(false) 93===Done=== 94