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