1--TEST--
2imap_fetchheader() errors: ValueError and Warnings
3--SKIPIF--
4<?php
5require_once(__DIR__.'/setup/skipif.inc');
6?>
7--FILE--
8<?php
9
10require_once(__DIR__.'/setup/imap_include.inc');
11
12$imap_mail_box = setup_test_mailbox("imapfetchheadererrors", 0);
13
14try {
15    imap_fetchheader($imap_mail_box, -1);
16} catch (\ValueError $e) {
17    echo $e->getMessage() . \PHP_EOL;
18}
19try {
20    imap_fetchheader($imap_mail_box, 1, -1);
21} catch (\ValueError $e) {
22    echo $e->getMessage() . \PHP_EOL;
23}
24
25// Access not existing
26var_dump(imap_fetchheader($imap_mail_box, 255));
27var_dump(imap_fetchheader($imap_mail_box, 255, FT_UID));
28
29imap_close($imap_mail_box);
30
31?>
32--CLEAN--
33<?php
34$mailbox_suffix = 'imapfetchheadererrors';
35require_once(__DIR__ . '/setup/clean.inc');
36?>
37--EXPECTF--
38Create a temporary mailbox and add 0 msgs
39New mailbox created
40imap_fetchheader(): Argument #2 ($message_num) must be greater than 0
41imap_fetchheader(): Argument #3 ($flags) must be a bitmask of FT_UID, FT_PREFETCHTEXT, and FT_INTERNAL
42
43Warning: imap_fetchheader(): Bad message number in %s on line %d
44bool(false)
45
46Warning: imap_fetchheader(): UID does not exist in %s on line %d
47bool(false)
48