summaryrefslogtreecommitdiff
path: root/ext/imap/tests/imap_fetchbody_basic.phpt
blob: d0324383ea283753098c68061d270dc31cf68a42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
--TEST--
Test imap_fetchbody() function : basic functionality
--SKIPIF--
<?php
require_once(__DIR__.'/setup/skipif.inc');
?>
--FILE--
<?php
/*           [, int $options])
 * Description: Get a specific body section
 * Source code: ext/imap/php_imap.c
 */

echo "*** Testing imap_fetchbody() : basic functionality ***\n";
require_once(__DIR__.'/setup/imap_include.inc');

// Initialise all required variables

// set up mailbox with one message
$stream_id = setup_test_mailbox('imapfetchbodybasic', 1, $mailbox, false);

$msg_no = 1;
$section = '2';
$options = array ('FT_UID' => FT_UID, 'FT_PEEK' => FT_PEEK, 'FT_INTERNAL' => FT_INTERNAL);

// Calling imap_fetchbody() with all possible arguments
echo "\n-- All possible arguments --\n";
foreach ($options as $key => $option) {
    echo "-- Option is $key --\n";
    switch ($key) {

        case 'FT_UID';
        $msg_uid = imap_uid($stream_id, $msg_no);
        var_dump( imap_fetchbody($stream_id, $msg_uid, $section, $option) );
        break;

        case 'FT_PEEK';
        var_dump( imap_fetchbody($stream_id, $msg_no, $section, $option) );
        $overview = imap_fetch_overview($stream_id, 1);
        echo "Seen Flag: ";
        var_dump( $overview[0]->seen );
        break;

        case 'FT_INTERNAL';
        var_dump( imap_fetchbody($stream_id, $msg_no, $section, $option) );
        break;

    }
}

// Calling imap_fetchbody() with mandatory arguments
echo "\n-- Mandatory arguments --\n";
var_dump( imap_fetchbody($stream_id, $msg_no, $section) );
$overview = imap_fetch_overview($stream_id, 1);
echo "Seen Flag: ";
var_dump( $overview[0]->seen );
?>
--CLEAN--
<?php
$mailbox_suffix = 'imapfetchbodybasic';
require_once(__DIR__.'/setup/clean.inc');
?>
--EXPECTF--
*** Testing imap_fetchbody() : basic functionality ***
Create a temporary mailbox and add 1 msgs
New mailbox created

-- All possible arguments --
-- Option is FT_UID --
string(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
-- Option is FT_PEEK --
string(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
Seen Flag: int(%d)
-- Option is FT_INTERNAL --
string(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"

-- Mandatory arguments --
string(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
Seen Flag: int(%d)