All pastes #1286945 Raw Edit

Stuff

public text v1 · immutable
#1286945 ·published 2008-12-16 17:21 UTC
rendered paste body
--TEST--
Test imap_body() 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);
if (!is_resource($stream_id)) {
	exit("TEST FAILED: Unable to create test mailbox\n");
}

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

// Calling imap_body() 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_body($stream_id, $msg_uid, $option) ) ) {echo "PASS\n";}
			if(is_string( imap_body($stream_id, $msg_uid, PHP_INT_MAX) ) ) {echo "PASS\n";}
	}else {
                        if(is_string( imap_body($stream_id, $msg_no, $option) ) ) {echo "PASS\n";}
                        if(is_string( imap_body($stream_id, $msg_no, PHP_INT_MAX) ) ) {echo "PASS\n";}
	}
}

echo "\n-- Mandatory arguments --\n";
if(is_string( imap_body($stream_id, $msg_no) ) ) {echo "PASS\n";}

imap_close($stream_id);
?>
===Done===
--CLEAN--
<?php 
require_once('clean.inc');
?>
--EXPECTF--
Create a temporary mailbox and add 1 msgs
.. mailbox '{localhost/norsh}INBOX.phpttest' created
-- Option is FT_UID --
PASS

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

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

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

-- Mandatory arguments --
PASS
===Done===