1--TEST-- 2Test imap_fetchbody() function : usage variations - $message_num arg 3--EXTENSIONS-- 4imap 5--SKIPIF-- 6<?php 7require_once(__DIR__.'/setup/skipif.inc'); 8?> 9--FILE-- 10<?php 11/* 12 * Pass different integers, strings, msg sequences and msg UIDs as $message_num argument 13 * to test behaviour of imap_fetchbody() 14 */ 15 16echo "*** Testing imap_fetchbody() : usage variations ***\n"; 17 18require_once(__DIR__.'/setup/imap_include.inc'); 19 20//Initialise required variables 21$stream_id = setup_test_mailbox('imapfetchbodyvar6', 3); // set up temp mailbox with simple msgs 22$section = 1; 23 24$sequences = [0, /* out of range */ 4, 1]; 25 26foreach($sequences as $message_num) { 27 echo "\n-- \$message_num is $message_num --\n"; 28 try { 29 var_dump(imap_fetchbody($stream_id, $message_num, $section)); 30 } catch (\ValueError $e) { 31 echo $e->getMessage() . \PHP_EOL; 32 } 33} 34?> 35--CLEAN-- 36<?php 37$mailbox_suffix = 'imapfetchbodyvar6'; 38require_once(__DIR__.'/setup/clean.inc'); 39?> 40--EXPECTF-- 41*** Testing imap_fetchbody() : usage variations *** 42Create a temporary mailbox and add 3 msgs 43New mailbox created 44 45-- $message_num is 0 -- 46imap_fetchbody(): Argument #2 ($message_num) must be greater than 0 47 48-- $message_num is 4 -- 49 50Warning: imap_fetchbody(): Bad message number in %s on line %d 51bool(false) 52 53-- $message_num is 1 -- 54string(%d) "1: this is a test message, please ignore 55newline%r\R?%r" 56