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