1--TEST--
2Test imap_fetchbody() function : usage variations - FT_UID option
3--SKIPIF--
4<?php
5require_once(__DIR__.'/setup/skipif.inc');
6?>
7--FILE--
8<?php
9/*
10 * Test if FT_UID is set by passing the following as $flags argument to imap_fetchbody():
11 * 1. values that equate to 1
12 * 2. Minimum and maximum PHP values
13 */
14echo "*** Testing imap_fetchbody() : usage variations ***\n";
15
16require_once(__DIR__.'/setup/imap_include.inc');
17
18// Initialise required variables
19$stream_id = setup_test_mailbox('imapfetchbodyvar4', 1); // set up temporary mailbox with one simple message
20$msg_no = 1;
21$msg_uid = imap_uid($stream_id, $msg_no);
22$section = 1;
23
24//Note: the first four values are valid as they will all be cast to 1L.
25$flags = array ('1', true,
26                  1.000000000000001, 0.00001e5,
27                  PHP_INT_MAX, -PHP_INT_MAX);
28
29// iterate over each element of $flags array to test whether FT_UID is set
30$iterator = 1;
31imap_check($stream_id);
32foreach($flags as $option) {
33    echo "\n-- Iteration $iterator --\n";
34
35    try {
36        if(is_string(imap_fetchbody($stream_id, $msg_uid, $section, $option))) {
37            echo "FT_UID valid\n";
38        } else {
39            echo "FT_UID not valid\n";
40        }
41    } catch (\ValueError $e) {
42        echo $e->getMessage() . \PHP_EOL;
43    }
44    $iterator++;
45}
46
47?>
48--CLEAN--
49<?php
50$mailbox_suffix = 'imapfetchbodyvar4';
51require_once(__DIR__.'/setup/clean.inc');
52?>
53--EXPECT--
54*** Testing imap_fetchbody() : usage variations ***
55Create a temporary mailbox and add 1 msgs
56New mailbox created
57
58-- Iteration 1 --
59FT_UID valid
60
61-- Iteration 2 --
62FT_UID valid
63
64-- Iteration 3 --
65FT_UID valid
66
67-- Iteration 4 --
68FT_UID valid
69
70-- Iteration 5 --
71imap_fetchbody(): Argument #4 ($flags) must be a bitmask of FT_UID, FT_PEEK, and FT_INTERNAL
72
73-- Iteration 6 --
74imap_fetchbody(): Argument #4 ($flags) must be a bitmask of FT_UID, FT_PEEK, and FT_INTERNAL
75