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