Annotation of embedaddon/php/ext/imap/tests/imap_bodystruct_basic.phpt, revision 1.1.1.1
1.1 misho 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:
14: echo "*** Testing string imap_bodystruct : basic functionality ***\n";
15: require_once(dirname(__FILE__).'/imap_include.inc');
16:
17: echo "Create a new mailbox for test and add a multipart msgs\n";
18: $imap_stream = setup_test_mailbox("", 1, $mailbox, "multipart");
19: if (!is_resource($imap_stream)) {
20: exit("TEST FAILED: Unable to create test mailbox\n");
21: }
22:
23: echo "\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:
36: foreach($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:
48: if(is_array($m->parameters))
49: {
50: echo "parameters is an array\n";
51: }
52:
53: echo "\nTry to get part 4!\n";
54: var_dump(imap_bodystruct($imap_stream, 1, "4"));
55:
56: imap_close($imap_stream);
57:
58: function isValid($param)
59: {
60: if(($param == 0) || ($param == 1))
61: {
62: $result=true;
63: }
64: else
65: {
66: $result=false;
67: }
68: return $result;
69: }
70: ?>
71: ===Done===
72: --CLEAN--
73: <?php
74: require_once('clean.inc');
75: ?>
76: --EXPECTF--
77: *** Testing string imap_bodystruct : basic functionality ***
78: Create a new mailbox for test and add a multipart msgs
79: Create a temporary mailbox and add 1 msgs
80: .. mailbox '{%s}%s' created
81:
82: Get and validate structure of body part 1
83: ifsubtype is 0 or 1
84: ifdescription is 0 or 1
85: ifid is 0 or 1
86: ifdisposition is 0 or 1
87: ifdparameters is 0 or 1
88: ifparameters is 0 or 1
89: parameters is an array
90:
91: Try to get part 4!
92: bool(false)
93: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>