All pastes #1286947 Raw Edit

Mine

public text v1 · immutable
#1286947 ·published 2008-12-16 17:22 UTC
rendered paste body
--TEST--
Test imap_fetchbody() function : basic functionality
--SKIPIF--
<?php
require_once(dirname(__FILE__).'/skipif.inc');
?>
--FILE--
<?php
require_once(dirname(__FILE__).'/imap_include.inc');

$stream_id = setup_test_mailbox('', 1, $mailbox, 'notSimple');

$msg_no = 1;
$section = '2';
$options = array ('FT_UID' => FT_UID, 'FT_PEEK' => FT_PEEK, 'FT_INTERNAL' => FT_INTERNAL);

// Calling imap_fetchbody() with all possible arguments
foreach ($options as $key => $option) {
	echo "-- Option is $key --\n";
        if ($key == 'FT_UID') {
		$msg_uid = imap_uid($stream_id, $msg_no);
		if(is_string( imap_fetchbody($stream_id, $msg_uid, $section, $option) ) ) {echo "PASS\n";}
		if(is_string( imap_fetchbody($stream_id, $msg_uid, $section, PHP_INT_MAX) ) ) {echo "PASS\n";}
	} else {
                if(is_string( imap_fetchbody($stream_id, $msg_no, $section, $option) ) ) {echo "PASS\n";}
                if(is_string( imap_fetchbody($stream_id, $msg_no, $section, PHP_INT_MAX) ) ) {echo "PASS\n";}
        }
}

echo "\n-- Mandatory arguments --\n";
if(is_string( imap_fetchbody($stream_id, $msg_no, $section) ) ) {echo "PASS\n";}
?>
===DONE===
--CLEAN--
<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
--EXPECTF--
Create a temporary mailbox and add 1 msgs
.. mailbox '{localhost/norsh}INBOX.phpttest' created
-- Option is FT_UID --
PASS

Warning: imap_fetchbody(): invalid value for the options parameter in %s on line %d
-- Option is FT_PEEK --
PASS

Warning: imap_fetchbody(): invalid value for the options parameter in %s on line %d
-- Option is FT_INTERNAL --
PASS

Warning: imap_fetchbody(): invalid value for the options parameter in %s on line %d

-- Mandatory arguments --
PASS
===DONE===