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