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