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