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