import zend imap tests

Esse commit está contido em:
Paul Tarjan
2013-04-22 18:23:21 -07:00
commit de Sara Golemon
commit 042ea354d0
155 arquivos alterados com 4893 adições e 1 exclusões
+27
Ver Arquivo
@@ -0,0 +1,27 @@
<?php
$envelope["from"]= "joe@example.com";
$envelope["to"] = "foo@example.com";
$envelope["cc"] = "bar@example.com";
$part1["type"] = TYPEMULTIPART;
$part1["subtype"] = "mixed";
$part2["type"] = TYPEAPPLICATION;
$part2["encoding"] = ENCBINARY;
$part2["subtype"] = "octet-stream";
$part2["description"] = "some file";
$part2["contents.data"] = "ABC";
$part3["type"] = TYPETEXT;
$part3["subtype"] = "plain";
$part3["description"] = "description3";
$part3["contents.data"] = "contents.data3\n\n\n\t";
$body[1] = $part1;
$body[2] = $part2;
$body[3] = $part3;
echo imap_mail_compose($envelope, $body);
?>
@@ -0,0 +1,22 @@
From: joe@example.com
To: foo@example.com
cc: bar@example.com
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="%s"
--%s
Content-Type: APPLICATION/octet-stream
Content-Transfer-Encoding: BASE64
Content-Description: some file
QUJD
--%s
Content-Type: TEXT/plain; CHARSET=US-ASCII
Content-Description: description3
contents.data3
--%s--
+14
Ver Arquivo
@@ -0,0 +1,14 @@
<?php
$envelope["from"]= 'host@domain.com';
$envelope["return_path"]= 'host@domain.com';
$part1["type"]=TYPETEXT;
$part1["subtype"]="plain";
$part1["encoding"]=ENCQUOTEDPRINTABLE ;
$part1["charset"]='iso-8859-2';
$part1["contents.data"]=imap_8bit('asn řkl');
$body = array($part1);
echo imap_mail_compose($envelope, $body);
?>
@@ -0,0 +1,6 @@
From: host@domain.com
MIME-Version: 1.0
Content-Type: TEXT/plain; CHARSET=iso-8859-2
Content-Transfer-Encoding: QUOTED-PRINTABLE
asn =C5=99kl
+15
Ver Arquivo
@@ -0,0 +1,15 @@
<?php
$m_envelope["To"] = "mail@example.com";
$m_part1["type"] = TYPEMULTIPART;
$m_part1["subtype"] = "mixed";
$m_part2["type"] = TYPETEXT;
$m_part2["subtype"] = "plain";
$m_part2["description"] = "text_message";
$m_part2["charset"] = "ISO-8859-2";
$m_part2["contents.data"] = "hello";
$m_body[1] = $m_part1;
$m_body[2] = $m_part2;
echo imap_mail_compose($m_envelope, $m_body);
?>
@@ -0,0 +1,9 @@
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="%s"
%s
Content-Type: TEXT/plain; CHARSET=ISO-8859-2
Content-Description: text_message
hello
%s
+35
Ver Arquivo
@@ -0,0 +1,35 @@
<?php
$envelope["from"] = 'Santa <somewhere@northpole.gov>';
$envelope["to"] = 'The bad smurf <bad@smurf.com>';
$envelope['date'] = 'Wed, 04 Jan 2006 19:24:43 -0500';
$multipart["type"] = TYPEMULTIPART;
$multipart["subtype"] = "MIXED";
$body[] = $multipart; //add multipart stuff
$textpart["type"] = TYPEMULTIPART;
$textpart["subtype"] = "ALTERNATIVE";
$body[] = $textpart; //add body part
$plain["type"] = TYPETEXT;
$plain["subtype"] = "PLAIN";
$plain["charset"] = "iso-8859-1";
$plain["encoding"] = ENCQUOTEDPRINTABLE;
$plain["description"] = "Plaintype part of message";
$plain['disposition'] = "inline";
$plain["contents.data"] = 'See mom, it will crash';
$body[] = $plain; //next add plain text part
$html["type"] = TYPETEXT;
$html["subtype"] = "HTML";
$html["charset"] = "iso-8859-1";
$html["encoding"] = ENCQUOTEDPRINTABLE;
$html["description"] = "HTML part of message";
$html['disposition'] = "inline";
$html["contents.data"] = 'See mom, it will <b>crash</b>';
$body[] = $html;
echo imap_mail_compose($envelope, $body);
?>
@@ -0,0 +1,23 @@
Date: Wed, 04 Jan 2006 19:24:43 -0500
From: Santa <somewhere@northpole.gov>
To: The bad smurf <bad@smurf.com>
MIME-Version: 1.0
Content-Type: MULTIPART/MIXED; BOUNDARY="%s"
--%s
Content-Type: TEXT/ALTERNATIVE; CHARSET=US-ASCII
--%s
Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE
Content-Description: Plaintype part of message
See mom, it will crash
--%s
Content-Type: TEXT/HTML; CHARSET=iso-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE
Content-Description: HTML part of message
See mom, it will <b>crash</b>
--%s--
+25
Ver Arquivo
@@ -0,0 +1,25 @@
<?php
$envelope["from"]= "joe@example.com";
$envelope["to"] = "foo@example.com";
$envelope["cc"] = "bar@example.com";
$part1["type"] = TYPEMULTIPART;
$part1["subtype"] = "mixed";
$part2["type"] = TYPEAPPLICATION;
$part2["encoding"] = ENCBINARY;
$part2["subtype"] = "octet-stream";
$part2["description"] = 'a.txt';
$part2["contents.data"] = '';
$part3["type"] = TYPETEXT;
$part3["subtype"] = "plain";
$part3["description"] = "description3";
$part3["contents.data"] = "contents.data3\n\n\n\t";
$body[1] = $part1;
$body[2] = $part2;
$body[3] = $part3;
echo imap_mail_compose($envelope, $body);
?>
@@ -0,0 +1,22 @@
From: joe@example.com
To: foo@example.com
cc: bar@example.com
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="%s"
--%s
Content-Type: APPLICATION/octet-stream
Content-Transfer-Encoding: BASE64
Content-Description: a.txt
--%s
Content-Type: TEXT/plain; CHARSET=US-ASCII
Content-Description: description3
contents.data3
--%s--
+8
Ver Arquivo
@@ -0,0 +1,8 @@
<?php
$address = 'John Doe <john@example.com>';
var_dump($address);
imap_rfc822_parse_adrlist($address, null);
var_dump($address);
?>
@@ -0,0 +1,2 @@
string(27) "John Doe <john@example.com>"
string(27) "John Doe <john@example.com>"
+15
Ver Arquivo
@@ -0,0 +1,15 @@
<?php
$envelope = array('return_path' => 'John Doe <john@example.com>',
'from' => 'John Doe <john@example.com>',
'reply_to' => 'John Doe <john@example.com>',
'to' => 'John Doe <john@example.com>',
'cc' => 'John Doe <john@example.com>',
'bcc' => 'John Doe <john@example.com>',
);
var_dump($envelope);
imap_mail_compose($envelope, array(1 => array()));
var_dump($envelope);
?>
@@ -0,0 +1,28 @@
array(6) {
["return_path"]=>
string(27) "John Doe <john@example.com>"
["from"]=>
string(27) "John Doe <john@example.com>"
["reply_to"]=>
string(27) "John Doe <john@example.com>"
["to"]=>
string(27) "John Doe <john@example.com>"
["cc"]=>
string(27) "John Doe <john@example.com>"
["bcc"]=>
string(27) "John Doe <john@example.com>"
}
array(6) {
["return_path"]=>
string(27) "John Doe <john@example.com>"
["from"]=>
string(27) "John Doe <john@example.com>"
["reply_to"]=>
string(27) "John Doe <john@example.com>"
["to"]=>
string(27) "John Doe <john@example.com>"
["cc"]=>
string(27) "John Doe <john@example.com>"
["bcc"]=>
string(27) "John Doe <john@example.com>"
}
+14
Ver Arquivo
@@ -0,0 +1,14 @@
<?php
$adds = 'ian eiloart <iane@example.ac.uk>,
shuf6@example.ac.uk,
blobby,
"ian,eiloart"<ian@example.ac.uk>,
<@example.com:foo@example.ac.uk>,
foo@#,
ian@-example.com,
ian@one@two';
$add_arr = imap_rfc822_parse_adrlist($adds, 'example.com');
var_export($add_arr);
?>
@@ -0,0 +1,51 @@
array (
0 =>
stdClass::__set_state(array(
'mailbox' => 'iane',
'host' => 'example.ac.uk',
'personal' => 'ian eiloart',
)),
1 =>
stdClass::__set_state(array(
'mailbox' => 'shuf6',
'host' => 'example.ac.uk',
)),
2 =>
stdClass::__set_state(array(
'mailbox' => 'blobby',
'host' => 'example.com',
)),
3 =>
stdClass::__set_state(array(
'mailbox' => 'ian',
'host' => 'example.ac.uk',
'personal' => 'ian,eiloart',
)),
4 =>
stdClass::__set_state(array(
'mailbox' => 'foo',
'host' => 'example.ac.uk',
'adl' => '@example.com',
)),
5 =>
stdClass::__set_state(array(
'mailbox' => 'foo',
'host' => '#',
)),
6 =>
stdClass::__set_state(array(
'mailbox' => 'ian',
'host' => '-example.com',
)),
7 =>
stdClass::__set_state(array(
'mailbox' => 'ian',
'host' => 'one',
)),
8 =>
stdClass::__set_state(array(
'mailbox' => 'UNEXPECTED_DATA_AFTER_ADDRESS',
'host' => '.SYNTAX-ERROR.',
)),
)
HipHop Notice: %a
+5
Ver Arquivo
@@ -0,0 +1,5 @@
<?php
$s = "=?UTF-8?Q?=E2=82=AC?=";
$header = "$s\n $s\n\t$s";
var_dump(imap_mime_header_decode($header));
@@ -0,0 +1,23 @@
array(3) {
[0]=>
object(stdClass)#1 (2) {
["charset"]=>
string(5) "UTF-8"
["text"]=>
string(3) "€"
}
[1]=>
object(stdClass)#2 (2) {
["charset"]=>
string(5) "UTF-8"
["text"]=>
string(3) "€"
}
[2]=>
object(stdClass)#3 (2) {
["charset"]=>
string(5) "UTF-8"
["text"]=>
string(3) "€"
}
}
+23
Ver Arquivo
@@ -0,0 +1,23 @@
<?php
$tests = array(
'Array' => array('DISABLE_AUTHENTICATOR' => array('GSSAPI','NTLM')),
'String' => array('DISABLE_AUTHENTICATOR' => 'GSSAPI'),
);
require_once(dirname(__FILE__).'/imap_include.inc');
foreach ($tests as $name => $testparams) {
echo "Test for $name\n";
$in = imap_open($default_mailbox, $username, $password, OP_HALFOPEN, 1, $testparams);
if ($in) {
if (is_array($errors = imap_errors())) {
foreach ($errors as $err) {
if (strstr($err, 'GSSAPI') || strstr($err, 'Kerberos')) {
echo "$err\n";
}
}
}
} else {
echo "Can't connect\n";
}
}
echo "Done\n";
?>
@@ -0,0 +1,3 @@
Test for Array
Test for String
Done
@@ -0,0 +1,17 @@
<?php
/* Prototype : string imap_8bit ( string $string )
* Description: Convert an 8bit string to a quoted-printable string.
* Source code: ext/imap/php_imap.c
*/
echo "*** Testing imap_8bit() : basic functionality ***\n";
var_dump(imap_8bit("String with CRLF at end \r\n"));
//NB this appears to be a bug in cclient; a space at end of string should be encoded as =20
var_dump(imap_8bit("String with space at end "));
var_dump(imap_8bit("String with tabs \t\t in middle"));
var_dump(imap_8bit("String with tab at end \t"));
var_dump(imap_8bit("\x00\x01\x02\x03\x04\xfe\xff\x0a\x0d"));
?>
===Done===
@@ -0,0 +1,8 @@
*** Testing imap_8bit() : basic functionality ***
string(28) "String with CRLF at end=20
"
string(25) "String with space at end "
string(33) "String with tabs =09=09 in middle"
string(26) "String with tab at end =09"
string(27) "=00=01=02=03=04=FE=FF=0A=0D"
===Done===
@@ -0,0 +1,45 @@
<?php
/* Prototype : bool imap_append ( resource $imap_stream , string $mailbox , string $message [, string $options ] )
* Description: Append a string message to a specified mailbox.
* Source code: ext/imap/php_imap.c
*/
echo "*** Testing imap_append() : basic functionality ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
echo "Create a new mailbox for test\n";
$imap_stream = setup_test_mailbox("", 0);
if (!is_resource($imap_stream)) {
exit("TEST FAILED: Unable to create test mailbox\n");
}
$mb_details = imap_mailboxmsginfo($imap_stream);
echo "Add a couple of msgs to new mailbox " . $mb_details->Mailbox . "\n";
var_dump(imap_append($imap_stream, $mb_details->Mailbox
, "From: webmaster@something.com\r\n"
. "To: info@something.com\r\n"
. "Subject: Test message\r\n"
. "\r\n"
. "this is a test message, please ignore\r\n"
));
var_dump(imap_append($imap_stream, $mb_details->Mailbox
, "From: webmaster@something.com\r\n"
. "To: info@something.com\r\n"
. "Subject: Another test\r\n"
. "\r\n"
. "this is another test message, please ignore it too!!\r\n"
));
$check = imap_check($imap_stream);
echo "Msg Count after append : ". $check->Nmsgs . "\n";
echo "List the msg headers\n";
var_dump(imap_headers($imap_stream));
imap_close($imap_stream);
?>
===Done===<?php
require_once('clean.inc');
?>
@@ -0,0 +1,16 @@
*** Testing imap_append() : basic functionality ***
Create a new mailbox for test
Create a temporary mailbox and add 0 msgs
.. mailbox '%s' created
Add a couple of msgs to new mailbox {%s}INBOX.%s
bool(true)
bool(true)
Msg Count after append : 2
List the msg headers
array(2) {
[0]=>
string(%d) "%w%s 1)%s webmaster@something. Test message (%d chars)"
[1]=>
string(%d) "%w%s 2)%s webmaster@something. Another test (%d chars)"
}
===Done===
+20
Ver Arquivo
@@ -0,0 +1,20 @@
<?php
echo "Checking with no parameters\n";
imap_body();
echo "Checking with incorrect parameter type\n";
imap_body('');
imap_body(false);
require_once(dirname(__FILE__).'/imap_include.inc');
$stream_id = imap_open($default_mailbox, $username, $password) or
die("Cannot connect to mailbox $default_mailbox: " . imap_last_error());
imap_body($stream_id);
imap_body($stream_id,-1);
imap_body($stream_id,1,-1);
//Access not existing
var_dump(imap_body($stream_id, 999, FT_UID));
imap_close($stream_id);
?>
@@ -0,0 +1,10 @@
Checking with no parameters
HipHop Warning: %a
Checking with incorrect parameter type
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a
bool(false)
@@ -0,0 +1,30 @@
<?php
/* Prototype : string imap_body ( resource $imap_stream , int $msg_number [, int $options ] )
* Description: Read the message body.
* Source code: ext/imap/php_imap.c
*/
echo "*** Testing imap_body() : basic functionality ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
echo "Create a new mailbox for test\n";
$imap_stream = setup_test_mailbox("", 1);
if (!is_resource($imap_stream)) {
exit("TEST FAILED: Unable to create test mailbox\n");
}
$check = imap_check($imap_stream);
echo "Msg Count in new mailbox: ". $check->Nmsgs . "\n";
// show body for msg 1
var_dump(imap_body($imap_stream, 1));
//Access via FT_UID
var_dump(imap_body($imap_stream, 1, FT_UID));
imap_close($imap_stream);
?>
===Done===<?php
require_once('clean.inc');
?>
@@ -0,0 +1,8 @@
*** Testing imap_body() : basic functionality ***
Create a new mailbox for test
Create a temporary mailbox and add 1 msgs
.. mailbox '%s' created
Msg Count in new mailbox: 1
%unicode|string%(%d) "1: this is a test message, please ignore%a"
%unicode|string%(%d) "1: this is a test message, please ignore%a"
===Done===
@@ -0,0 +1,66 @@
<?php
/* Prototype : object imap_bodystruct ( resource $imap_stream , int $msg_number , string $section )
* Description: Read the structure of a specified body section of a specific message.
* Source code: ext/imap/php_imap.c
*/
echo "*** Testing string imap_bodystruct : basic functionality ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
echo "Create a new mailbox for test and add a multipart msgs\n";
$imap_stream = setup_test_mailbox("", 1, $mailbox, "multipart");
if (!is_resource($imap_stream)) {
exit("TEST FAILED: Unable to create test mailbox\n");
}
echo "\nGet and validate structure of body part 1\n";
$m = imap_bodystruct($imap_stream, 1, "1");
$mandatoryFields = array(
'ifsubtype',
'ifdescription',
'ifid',
'ifdisposition',
'ifdparameters',
'ifparameters',
);
foreach($mandatoryFields as $mf)
{
if(isValid($m->$mf))
{
echo "$mf is 0 or 1\n";
}
else
{
echo "$mf FAIL\n";
}
}
if(is_array($m->parameters))
{
echo "parameters is an array\n";
}
echo "\nTry to get part 4!\n";
var_dump(imap_bodystruct($imap_stream, 1, "4"));
imap_close($imap_stream);
function isValid($param)
{
if(($param == 0) || ($param == 1))
{
$result=true;
}
else
{
$result=false;
}
return $result;
}
?>
===Done===<?php
require_once('clean.inc');
?>
@@ -0,0 +1,17 @@
*** Testing string imap_bodystruct : basic functionality ***
Create a new mailbox for test and add a multipart msgs
Create a temporary mailbox and add 1 msgs
.. mailbox '{%s}%s' created
Get and validate structure of body part 1
ifsubtype is 0 or 1
ifdescription is 0 or 1
ifid is 0 or 1
ifdisposition is 0 or 1
ifdparameters is 0 or 1
ifparameters is 0 or 1
parameters is an array
Try to get part 4!
bool(false)
===Done===
@@ -0,0 +1,45 @@
<?php
/* Prototype : bool imap_clearflag_full ( resource $imap_stream , string $sequence , string $flag [, string $options ] )
* Description: Clears flags on messages.
* Source code: ext/imap/php_imap.c
*/
echo "*** Testing imap_clearflag_full() : basic functionality ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
echo "Create a new mailbox for test\n";
$imap_stream = setup_test_mailbox("", 10);
if (!is_resource($imap_stream)) {
exit("TEST FAILED: Unable to create test mailbox\n");
}
$check = imap_check($imap_stream);
echo "Initial msg count in new_mailbox : ". $check->Nmsgs . "\n";
echo "Set some flags\n";
var_dump(imap_setflag_full($imap_stream, "1,3", "\\Seen \\Answered"));
var_dump(imap_setflag_full($imap_stream, "2,4", "\\Answered"));
var_dump(imap_setflag_full($imap_stream, "5,7", "\\Flagged \\Deleted"));
var_dump(imap_setflag_full($imap_stream, "6,8", "\\Deleted"));
var_dump(imap_setflag_full($imap_stream, "9,10", "\\Draft \\Flagged"));
var_dump(imap_search($imap_stream, "SEEN"));
var_dump(imap_search($imap_stream, "ANSWERED"));
var_dump(imap_search($imap_stream, "FLAGGED"));
var_dump(imap_search($imap_stream, "DELETED"));
var_dump(imap_clearflag_full($imap_stream, "1,4", "\\Answered"));
var_dump(imap_clearflag_full($imap_stream, "5,6,7,8", "\\Deleted"));
var_dump(imap_clearflag_full($imap_stream, "9", "\\Flagged"));
var_dump(imap_search($imap_stream, "SEEN"));
var_dump(imap_search($imap_stream, "ANSWERED"));
var_dump(imap_search($imap_stream, "FLAGGED"));
var_dump(imap_search($imap_stream, "DELETED"));
imap_close($imap_stream);
?>
===Done===<?php
require_once('clean.inc');
?>
@@ -0,0 +1,72 @@
*** Testing imap_clearflag_full() : basic functionality ***
Create a new mailbox for test
Create a temporary mailbox and add 10 msgs
.. mailbox '{%s}%s' created
Initial msg count in new_mailbox : 10
Set some flags
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
array(2) {
[0]=>
int(1)
[1]=>
int(3)
}
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
}
array(4) {
[0]=>
int(5)
[1]=>
int(7)
[2]=>
int(9)
[3]=>
int(10)
}
array(4) {
[0]=>
int(5)
[1]=>
int(6)
[2]=>
int(7)
[3]=>
int(8)
}
bool(true)
bool(true)
bool(true)
array(2) {
[0]=>
int(1)
[1]=>
int(3)
}
array(2) {
[0]=>
int(2)
[1]=>
int(3)
}
array(3) {
[0]=>
int(5)
[1]=>
int(7)
[2]=>
int(10)
}
bool(false)
===Done===
@@ -0,0 +1,35 @@
<?php
/* Prototype : bool imap_close(resource $stream_id [, int $options])
* Description: Close an IMAP stream
* Source code: ext/imap/php_imap.c
*/
echo "*** Testing imap_close() : basic functionality ***\n";
// include file for required variables in imap_open()
require_once(dirname(__FILE__).'/imap_include.inc');
// Initialize required variables
$stream_id = setup_test_mailbox('', 3, $mailbox); // set up temp mailbox with 3 messages
$options = CL_EXPUNGE;
// mark messages in inbox for deletion
for ($i = 1; $i < 4; $i++) {
imap_delete($stream_id, $i);
}
// Calling imap_close() with all possible arguments
echo "\n-- Call to imap_close() with all possible arguments --\n";
var_dump( imap_close($stream_id, $options) );
// check that CL_EXPUNGE worked
$stream_id = imap_open($mailbox, $username, $password);
echo "There are now " . imap_num_msg($stream_id) . " msgs in mailbox '$mailbox'\n";
// Calling imap_close() with mandatory arguments
echo "\n-- Call to imap_close() with mandatory arguments --\n";
var_dump( imap_close($stream_id) );
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,11 @@
*** Testing imap_close() : basic functionality ***
Create a temporary mailbox and add 3 msgs
.. mailbox '%sINBOX.phpttest' created
-- Call to imap_close() with all possible arguments --
bool(true)
There are now 0 msgs in mailbox '%sINBOX.phpttest'
-- Call to imap_close() with mandatory arguments --
bool(true)
===DONE===
@@ -0,0 +1,25 @@
<?php
/* Prototype : bool imap_close(resource $stream_id [, int $options])
* Description: Close an IMAP stream
* Source code: ext/imap/php_imap.c
*/
/*
* Pass an incorrect number of arguments to imap_close() to test behaviour
*/
echo "*** Testing imap_close() : error conditions ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
// Zero arguments
echo "\n-- Testing imap_close() function with Zero arguments --\n";
var_dump( imap_close() );
//Test imap_close with one more than the expected number of arguments
echo "\n-- Testing imap_close() function with more than expected no. of arguments --\n";
$stream_id = imap_open($server, $username, $password);
$options = CL_EXPUNGE;
$extra_arg = 10;
var_dump( imap_close($stream_id, $options, $extra_arg) );
?>
===DONE===
@@ -0,0 +1,10 @@
*** Testing imap_close() : error conditions ***
-- Testing imap_close() function with Zero arguments --
HipHop Warning: %a
NULL
-- Testing imap_close() function with more than expected no. of arguments --
HipHop Warning: %a
NULL
===DONE===
@@ -0,0 +1,84 @@
<?php
/* Prototype : bool imap_close(resource $stream_id [, int $options])
* Description: Close an IMAP stream
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different data types as $stream_id argument to test behaviour of imap_close()
*/
echo "*** Testing imap_close() : usage variations ***\n";
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a class
class classA
{
public function __toString() {
return "Class A object";
}
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// unexpected values to be passed to $stream_id argument
$inputs = array(
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
/*12*/ true,
false,
TRUE,
FALSE,
// empty data
/*16*/ "",
'',
array(),
// string data
/*19*/ "string",
'string',
$heredoc,
// object data
/*22*/ new classA(),
// undefined data
/*23*/ @$undefined_var,
// unset data
/*24*/ @$unset_var,
);
// loop through each element of $inputs to check the behavior of imap_close()
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Iteration $iterator --\n";
var_dump( imap_close($input) );
$iterator++;
};
?>
===DONE===
@@ -0,0 +1,98 @@
*** Testing imap_close() : usage variations ***
-- Iteration 1 --
HipHop Warning: %a
NULL
-- Iteration 2 --
HipHop Warning: %a
NULL
-- Iteration 3 --
HipHop Warning: %a
NULL
-- Iteration 4 --
HipHop Warning: %a
NULL
-- Iteration 5 --
HipHop Warning: %a
NULL
-- Iteration 6 --
HipHop Warning: %a
NULL
-- Iteration 7 --
HipHop Warning: %a
NULL
-- Iteration 8 --
HipHop Warning: %a
NULL
-- Iteration 9 --
HipHop Warning: %a
NULL
-- Iteration 10 --
HipHop Warning: %a
NULL
-- Iteration 11 --
HipHop Warning: %a
NULL
-- Iteration 12 --
HipHop Warning: %a
NULL
-- Iteration 13 --
HipHop Warning: %a
NULL
-- Iteration 14 --
HipHop Warning: %a
NULL
-- Iteration 15 --
HipHop Warning: %a
NULL
-- Iteration 16 --
HipHop Warning: %a
NULL
-- Iteration 17 --
HipHop Warning: %a
NULL
-- Iteration 18 --
HipHop Warning: %a
NULL
-- Iteration 19 --
HipHop Warning: %a
NULL
-- Iteration 20 --
HipHop Warning: %a
NULL
-- Iteration 21 --
HipHop Warning: %a
NULL
-- Iteration 22 --
HipHop Warning: %a
NULL
-- Iteration 23 --
HipHop Warning: %a
NULL
-- Iteration 24 --
HipHop Warning: %a
NULL
===DONE===
@@ -0,0 +1,108 @@
<?php
/* Prototype : bool imap_close(resource $stream_id [, int $options])
* Description: Close an IMAP stream
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different data types as $options argument to test behaviour of imap_close()
*/
echo "*** Testing imap_close() : usage variations ***\n";
// include file for imap_stream
require_once(dirname(__FILE__).'/imap_include.inc');
// create mailbox to test whether options has been set to CL_EXPUNGE
$stream_id = setup_test_mailbox('', 3, $mailbox);
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// heredoc string
$heredoc = <<<EOT
32768
EOT;
// unexpected values to be passed to $options argument
$inputs = array(
// int data
/*1*/ 0,
1,
32768,
-2345,
// float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
/*12*/ true,
false,
TRUE,
FALSE,
// empty data
/*16*/ "",
'',
array(),
// string data
/*19*/ "32768",
'32768',
$heredoc,
// undefined data
/*22*/ @$undefined_var,
// unset data
/*23*/ @$unset_var,
);
// loop through each element of $inputs to check the behavior of imap_close()
$iterator = 1;
foreach($inputs as $input) {
// mark added messages for deletion
for ($i = 1; $i < 4; $i++) {
imap_delete($stream_id, $i);
}
echo "\n-- Iteration $iterator --\n";
var_dump( $check = imap_close($stream_id, $input) );
// check that imap_close was successful, if not call imap_close and explicitly set CL_EXPUNGE
if(false === $check) {
imap_close($stream_id, CL_EXPUNGE);
} else {
// if imap_close was successful test whether CL_EXPUNGE was set by doing a message count
$imap_stream = imap_open($mailbox, $username, $password);
$num_msg = imap_num_msg($imap_stream);
if ($num_msg != 0) {
echo "CL_EXPUNGE was not set, $num_msg msgs in mailbox\n";
} else {
echo "CL_EXPUNGE was set\n";
}
// call imap_close with CL_EXPUNGE explicitly set in case mailbox not empty
imap_close($imap_stream, CL_EXPUNGE);
}
$iterator++;
// get $stream_id for next iteration
$stream_id = imap_open($mailbox, $username, $password);
populate_mailbox($stream_id, $mailbox, 3);
};
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,99 @@
*** Testing imap_close() : usage variations ***
Create a temporary mailbox and add 3 msgs
.. mailbox '{%s}%s' created
-- Iteration 1 --
bool(true)
CL_EXPUNGE was not set, 3 msgs in mailbox
-- Iteration 2 --
HipHop Warning: %a
bool(false)
-- Iteration 3 --
bool(true)
CL_EXPUNGE was set
-- Iteration 4 --
HipHop Warning: %a
bool(false)
-- Iteration 5 --
HipHop Warning: %a
bool(false)
-- Iteration 6 --
HipHop Warning: %a
bool(false)
-- Iteration 7 --
HipHop Warning: %a
bool(false)
-- Iteration 8 --
bool(true)
CL_EXPUNGE was not set, 3 msgs in mailbox
-- Iteration 9 --
bool(true)
CL_EXPUNGE was not set, 3 msgs in mailbox
-- Iteration 10 --
bool(true)
CL_EXPUNGE was not set, 3 msgs in mailbox
-- Iteration 11 --
bool(true)
CL_EXPUNGE was not set, 3 msgs in mailbox
-- Iteration 12 --
HipHop Warning: %a
bool(false)
-- Iteration 13 --
bool(true)
CL_EXPUNGE was not set, 3 msgs in mailbox
-- Iteration 14 --
HipHop Warning: %a
bool(false)
-- Iteration 15 --
bool(true)
CL_EXPUNGE was not set, 3 msgs in mailbox
-- Iteration 16 --
HipHop Warning: %a
NULL
CL_EXPUNGE was not set, 3 msgs in mailbox
-- Iteration 17 --
HipHop Warning: %a
NULL
CL_EXPUNGE was not set, 3 msgs in mailbox
-- Iteration 18 --
HipHop Warning: %a
NULL
CL_EXPUNGE was not set, 3 msgs in mailbox
-- Iteration 19 --
bool(true)
CL_EXPUNGE was set
-- Iteration 20 --
bool(true)
CL_EXPUNGE was set
-- Iteration 21 --
bool(true)
CL_EXPUNGE was set
-- Iteration 22 --
bool(true)
CL_EXPUNGE was not set, 3 msgs in mailbox
-- Iteration 23 --
bool(true)
CL_EXPUNGE was not set, 3 msgs in mailbox
===DONE===
@@ -0,0 +1,23 @@
<?php
/* Prototype : bool imap_close(resource $stream_id [, int $options])
* Description: Close an IMAP stream
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different stream types to imap_close() to test whether it can close them
*/
echo "*** Testing imap_close() : usage variations ***\n";
echo "\n-- File Resource opened with fopen() --\n";
var_dump($file_handle = fopen(__FILE__, 'r'));
var_dump(imap_close($file_handle));
var_dump($file_handle);
echo "\n-- Directory Resource opened with opendir() --\n";
var_dump($dir_handle = opendir(dirname(__FILE__)));
var_dump(imap_close($dir_handle));
var_dump($dir_handle);
?>
===DONE===
@@ -0,0 +1,14 @@
*** Testing imap_close() : usage variations ***
-- File Resource opened with fopen() --
resource(%d) of type (stream)
HipHop Warning: %a
bool(false)
resource(%d) of type (stream)
-- Directory Resource opened with opendir() --
resource(%d) of type (stream)
HipHop Warning: %a
bool(false)
resource(%d) of type (stream)
===DONE===
@@ -0,0 +1,56 @@
<?php
/* Prototype : bool imap_close(resource $stream_id [, int $options])
* Description: Close an IMAP stream
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different integers as $options arg to imap_close() to test which are
* recognised as CL_EXPUNGE option
*/
echo "*** Testing imap_close() : usage variations ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
$inputs = array (0, 3.2768e4, -32768, PHP_INT_MAX, -PHP_INT_MAX);
$stream_id = setup_test_mailbox('', 3, $mailbox); // set up temp mailbox with 3 messages
// loop through each element of $inputs to check the behavior of imap_close()
$iterator = 1;
foreach($inputs as $input) {
// mark added messages for deletion
for ($i = 1; $i < 4; $i++) {
imap_delete($stream_id, $i);
}
echo "\n-- Iteration $iterator --\n";
var_dump( $check = imap_close($stream_id, $input) );
// check that imap_close was successful, if not call imap_close and explicitly set CL_EXPUNGE
if(false === $check) {
imap_close($stream_id, CL_EXPUNGE);
} else {
// if imap_close was successful test whether CL_EXPUNGE was set by doing a message count
$imap_stream = imap_open($mailbox, $username, $password);
$num_msg = imap_num_msg($imap_stream);
if ($num_msg != 0) {
echo "CL_EXPUNGE was not set, $num_msg msgs in mailbox\n";
} else {
echo "CL_EXPUNGE was set\n";
}
// call imap_close with CL_EXPUNGE explicitly set in case mailbox not empty
imap_close($imap_stream, CL_EXPUNGE);
}
$iterator++;
// get $stream_id for next iteration
$stream_id = imap_open($mailbox, $username, $password);
populate_mailbox($stream_id, $mailbox, 3);
};
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,24 @@
*** Testing imap_close() : usage variations ***
Create a temporary mailbox and add 3 msgs
.. mailbox '{%s}%s' created
-- Iteration 1 --
bool(true)
CL_EXPUNGE was not set, 3 msgs in mailbox
-- Iteration 2 --
bool(true)
CL_EXPUNGE was set
-- Iteration 3 --
HipHop Warning: %a
bool(false)
-- Iteration 4 --
HipHop Warning: %a
bool(false)
-- Iteration 5 --
HipHop Warning: %a
bool(false)
===DONE===
@@ -0,0 +1,50 @@
<?php
/* Prototype : bool imap_createmailbox ( resource $imap_stream , string $mailbox )
* Description: Creates a new mailbox specified by mailbox .
* Source code: ext/imap/php_imap.c
*/
echo "*** Testing imap_createmailbox() : basic functionality ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
$imap_stream = imap_open($default_mailbox, $username, $password) or
die("Cannot connect to mailbox $default_mailbox: " . imap_last_error());
$newname = "phpnewbox";
echo "Newname will be '$newname'\n";
$newbox = imap_utf7_encode($server.$newname);
if (imap_createmailbox($imap_stream, $newbox)) {
echo "Add a couple of msgs to '$newname' mailbox\n";
populate_mailbox($imap_stream, $newbox, 2);
$status = imap_status($imap_stream, $newbox, SA_ALL);
if ($status) {
echo "Your new mailbox '$newname' has the following status:\n";
echo "Messages: " . $status->messages . "\n";
echo "Recent: " . $status->recent . "\n";
echo "Unseen: " . $status->unseen . "\n";
echo "UIDnext: " . $status->uidnext . "\n";
echo "UIDvalidity: " . $status->uidvalidity . "\n";
} else {
echo "imap_status on new mailbox failed: " . imap_last_error() . "\n";
}
if (imap_deletemailbox($imap_stream, $newbox)) {
echo "Mailbox '$newname' removed to restore initial state\n";
} else {
echo "imap_deletemailbox on new mailbox failed: " . implode("\n", imap_errors()) . "\n";
}
} else {
echo "could not create new mailbox: " . implode("\n", imap_errors()) . "\n";
}
imap_close($imap_stream);
?>
===Done===
@@ -0,0 +1,11 @@
*** Testing imap_createmailbox() : basic functionality ***
Newname will be 'phpnewbox'
Add a couple of msgs to 'phpnewbox' mailbox
Your new mailbox 'phpnewbox' has the following status:
Messages: 2
Recent: 2
Unseen: 2
UIDnext: %d
UIDvalidity: %d
Mailbox 'phpnewbox' removed to restore initial state
===Done===
@@ -0,0 +1,23 @@
<?php
/* Prototype : array imap_errors ( void )
* Description: Returns all of the IMAP errors that have occurred.
* Source code: ext/imap/php_imap.c
*/
echo "*** Testing imap_errors() : basic functionality ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
$password = "bogus"; // invalid password to use in this test
echo "Issue open with invalid password with normal default number of retries, i.e 3\n";
$mbox = imap_open($default_mailbox, $username, $password, OP_READONLY, 3);
echo "List any errors\n";
var_dump(imap_errors());
echo "\n\nIssue open with invalid password with retries == 1\n";
$mbox = imap_open($default_mailbox, $username, $password, OP_READONLY, 1);
echo "List any errors\n";
var_dump(imap_errors());
?>
===Done===
@@ -0,0 +1,22 @@
*** Testing imap_errors() : basic functionality ***
Issue open with invalid password with normal default number of retries, i.e 3
HipHop Warning: %a
List any errors
array(%d) {
[0]=>
string(%d) "%s"
[1]=>
string(%d) "%s"
[2]=>
string(%d) "%a
}
Issue open with invalid password with retries == 1
HipHop Warning: %a
List any errors
array(%d) {
[0]=>
string(%d) "%a
}
===Done===
@@ -0,0 +1,8 @@
<?php
echo "Checking with no parameters\n";
imap_num_recent();
echo "Checking with incorrect parameter type\n";
imap_num_recent('');
imap_num_recent(false);
?>
@@ -0,0 +1,5 @@
Checking with no parameters
HipHop Warning: %a
Checking with incorrect parameter type
HipHop Warning: %a
HipHop Warning: %a
@@ -0,0 +1,42 @@
<?php
/* Prototype : array imap_fetch_overview(resource $stream_id, int $msg_no [, int $options])
* Description: Read an overview of the information in the headers
* of the given message sequence
* Source code: ext/imap/php_imap.c
*/
echo "*** Testing imap_fetch_overview() : basic functionality ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
// create a new mailbox and add two new messages to it
$stream_id = setup_test_mailbox('', 2, $mailbox, 'notSimple');
// get UID for new message
$msg_no = imap_uid($stream_id, 1);
$options = FT_UID;
// Calling imap_fetch_overview() with all possible arguments
echo "\n-- All possible arguments --\n";
$a = imap_fetch_overview($stream_id, "$msg_no", $options) ;
echo "\n--> Object #1\n";
displayOverviewFields($a[0]);
// Calling imap_fetch_overview() with mandatory arguments
echo "\n-- Mandatory arguments --\n";
$a = imap_fetch_overview($stream_id, '1:2') ;
//first object in array
echo "\n--> Object #1\n";
displayOverviewFields($a[0]);
//Second object in array
echo "\n--> Object #2\n";
displayOverviewFields($a[1]);
imap_close($stream_id);
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,44 @@
*** Testing imap_fetch_overview() : basic functionality ***
Create a temporary mailbox and add 2 msgs
.. mailbox '{%s}%s' created
-- All possible arguments --
--> Object #1
size is %d
uid is %d
msgno is 1
recent is %d
flagged is 0
answered is 0
deleted is 0
seen is 0
draft is 0
udate is OK
-- Mandatory arguments --
--> Object #1
size is %d
uid is %d
msgno is 1
recent is %d
flagged is 0
answered is 0
deleted is 0
seen is 0
draft is 0
udate is OK
--> Object #2
size is %d
uid is %d
msgno is 2
recent is %d
flagged is 0
answered is 0
deleted is 0
seen is 0
draft is 0
udate is OK
===DONE===
@@ -0,0 +1,30 @@
<?php
/* Prototype : array imap_fetch_overview(resource $stream_id, int $msg_no [, int $options])
* Description: Read an overview of the information in the headers
* of the given message sequence
* Source code: ext/imap/php_imap.c
*/
/*
* Pass an incorrect number of arguments to imap_fetch_overview() to test behaviour
*/
echo "*** Testing imap_fetch_overview() : error conditions ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
//Test imap_fetch_overview with one more than the expected number of arguments
echo "\n-- Testing imap_fetch_overview() function with more than expected no. of arguments --\n";
$stream_id = setup_test_mailbox('', 2, $mailbox, 'notSimple'); // set up temp mailbox with 2 msgs
$msg_no = 1;
$options = FT_UID;
$extra_arg = 10;
var_dump( imap_fetch_overview($stream_id, $msg_no, $options, $extra_arg) );
// Testing imap_fetch_overview with one less than the expected number of arguments
echo "\n-- Testing imap_fetch_overview() function with less than expected no. of arguments --\n";
var_dump( imap_fetch_overview($stream_id) );
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,12 @@
*** Testing imap_fetch_overview() : error conditions ***
-- Testing imap_fetch_overview() function with more than expected no. of arguments --
Create a temporary mailbox and add 2 msgs
.. mailbox '{%s}%s' created
HipHop Warning: %a
NULL
-- Testing imap_fetch_overview() function with less than expected no. of arguments --
HipHop Warning: %a
NULL
===DONE===
@@ -0,0 +1,89 @@
<?php
/* Prototype : array imap_fetch_overview(resource $stream_id, int $msg_no [, int $options])
* Description: Read an overview of the information in the headers
* of the given message sequence
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different data types as $stream_id argument to imap_fetch_overview() to test behaviour
*/
echo "*** Testing imap_fetch_overview() : usage variations ***\n";
// Initialise function arguments not being substituted
$msg_no = 1;
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a class
class classA
{
public function __toString() {
return "Class A object";
}
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// unexpected values to be passed to $stream_id argument
$inputs = array(
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
/*12*/ true,
false,
TRUE,
FALSE,
// empty data
/*16*/ "",
'',
array(),
// string data
/*19*/ "string",
'string',
$heredoc,
// object data
/*22*/ new classA(),
// undefined data
/*23*/ @$undefined_var,
// unset data
/*24*/ @$unset_var,
);
// loop through each element of $inputs to check the behavior of imap_fetch_overview()
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Testing with first argument value: ";
var_dump($input);
var_dump( imap_fetch_overview($input, $msg_no) );
$iterator++;
};
?>
===DONE===
@@ -0,0 +1,100 @@
*** Testing imap_fetch_overview() : usage variations ***
-- Testing with first argument value: int(0)
HipHop Warning: %a
NULL
-- Testing with first argument value: int(1)
HipHop Warning: %a
NULL
-- Testing with first argument value: int(12345)
HipHop Warning: %a
NULL
-- Testing with first argument value: int(-2345)
HipHop Warning: %a
NULL
-- Testing with first argument value: float(10.5)
HipHop Warning: %a
NULL
-- Testing with first argument value: float(-10.5)
HipHop Warning: %a
NULL
-- Testing with first argument value: float(123456789000)
HipHop Warning: %a
NULL
-- Testing with first argument value: float(1.23456789E-9)
HipHop Warning: %a
NULL
-- Testing with first argument value: float(0.5)
HipHop Warning: %a
NULL
-- Testing with first argument value: NULL
HipHop Warning: %a
NULL
-- Testing with first argument value: NULL
HipHop Warning: %a
NULL
-- Testing with first argument value: bool(true)
HipHop Warning: %a
NULL
-- Testing with first argument value: bool(false)
HipHop Warning: %a
NULL
-- Testing with first argument value: bool(true)
HipHop Warning: %a
NULL
-- Testing with first argument value: bool(false)
HipHop Warning: %a
NULL
-- Testing with first argument value: %string|unicode%(0) ""
HipHop Warning: %a
NULL
-- Testing with first argument value: %string|unicode%(0) ""
HipHop Warning: %a
NULL
-- Testing with first argument value: array(0) {
}
HipHop Warning: %a
NULL
-- Testing with first argument value: %string|unicode%(6) "string"
HipHop Warning: %a
NULL
-- Testing with first argument value: %string|unicode%(6) "string"
HipHop Warning: %a
NULL
-- Testing with first argument value: %string|unicode%(11) "hello world"
HipHop Warning: %a
NULL
-- Testing with first argument value: object(classA)#1 (0) {
}
HipHop Warning: %a
NULL
-- Testing with first argument value: NULL
HipHop Warning: %a
NULL
-- Testing with first argument value: NULL
HipHop Warning: %a
NULL
===DONE===
@@ -0,0 +1,108 @@
<?php
/* Prototype : array imap_fetch_overview(resource $stream_id, int $msg_no [, int $options])
* Description: Read an overview of the information in the headers
* of the given message sequence
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different data types as $msg_no argument to imap_fetch_overview() to test behaviour
*/
echo "*** Testing imap_fetch_overview() : usage variations ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
// Initialise function arguments not being substituted
$stream_id = setup_test_mailbox('', 1, $mailbox, 'notSimple'); // set up temp mailbox with 1 msg
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a class
class classA
{
public function __toString() {
return "Class A object";
}
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// get a resource variable
$fp = fopen(__FILE__, "r");
// unexpected values to be passed to <<<ARGUMENT HERE>>> argument
$inputs = array(
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
/*12*/ true,
false,
TRUE,
FALSE,
// empty data
/*16*/ "",
'',
array(),
// string data
/*19*/ "string",
'string',
$heredoc,
// object data
/*22*/ new classA(),
// undefined data
/*23*/ @$undefined_var,
// unset data
/*24*/ @$unset_var,
// resource variable
/*25*/ $fp
);
// loop through each element of $inputs to check the behavior of imap_fetch_overview()
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Testing with second argument value: ";
var_dump($input);
$overview = imap_fetch_overview($stream_id, $input);
if (!$overview) {
echo imap_last_error() . "\n";
} else {
displayOverviewFields($overview[0]);
}
$iterator++;
};
fclose($fp);
// clear the error stack
imap_errors();
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,110 @@
*** Testing imap_fetch_overview() : usage variations ***
Create a temporary mailbox and add 1 msgs
.. mailbox '{%s}%s' created
-- Testing with second argument value: int(0)
Sequence out of range
-- Testing with second argument value: int(1)
size is %d
uid is %d
msgno is 1
recent is %d
flagged is 0
answered is 0
deleted is 0
seen is 0
draft is 0
udate is OK
-- Testing with second argument value: int(12345)
Sequence out of range
-- Testing with second argument value: int(-2345)
Syntax error in sequence
-- Testing with second argument value: float(10.5)
Sequence out of range
-- Testing with second argument value: float(-10.5)
Syntax error in sequence
-- Testing with second argument value: float(123456789000)
Sequence out of range
-- Testing with second argument value: float(1.23456789E-9)
Sequence syntax error
-- Testing with second argument value: float(0.5)
Sequence out of range
-- Testing with second argument value: NULL
Sequence out of range
-- Testing with second argument value: NULL
Sequence out of range
-- Testing with second argument value: bool(true)
size is %d
uid is %d
msgno is 1
recent is %d
flagged is 0
answered is 0
deleted is 0
seen is 0
draft is 0
udate is OK
-- Testing with second argument value: bool(false)
Sequence out of range
-- Testing with second argument value: bool(true)
size is %d
uid is %d
msgno is 1
recent is %d
flagged is 0
answered is 0
deleted is 0
seen is 0
draft is 0
udate is OK
-- Testing with second argument value: bool(false)
Sequence out of range
-- Testing with second argument value: %string|unicode%(0) ""
Sequence out of range
-- Testing with second argument value: %string|unicode%(0) ""
Sequence out of range
-- Testing with second argument value: array(0) {
}
HipHop Warning: %a
Sequence out of range
-- Testing with second argument value: %string|unicode%(6) "string"
Syntax error in sequence
-- Testing with second argument value: %string|unicode%(6) "string"
Syntax error in sequence
-- Testing with second argument value: %string|unicode%(11) "hello world"
Syntax error in sequence
-- Testing with second argument value: object(classA)#1 (0) {
}
Syntax error in sequence
-- Testing with second argument value: NULL
Syntax error in sequence
-- Testing with second argument value: NULL
Syntax error in sequence
-- Testing with second argument value: resource(%d) of type (stream)
HipHop Warning: %a
Syntax error in sequence
===DONE===
@@ -0,0 +1,46 @@
<?php
/* Prototype : array imap_fetch_overview(resource $stream_id, int $msg_no [, int $options])
* Description: Read an overview of the information in the headers of the given message sequence
* Source code: ext/imap/php_imap.c
*/
/*
* Test passing a range of values into the $options argument to imap_fetch_overview():
* 1. values that equate to 1
* 2. Minimum and maximum PHP values
*/
echo "*** Testing imap_fetch_overview() : usage variations ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
// Initialise required variables
$stream_id = setup_test_mailbox('', 1); // set up temporary mailbox with one simple message
$msg_no = 1;
$msg_uid = imap_uid($stream_id, $msg_no);
$options = array ('1',
true,
1.000000000000001,
0.00001e5,
PHP_INT_MAX,
-PHP_INT_MAX
);
// iterate over each element of $options array
$iterator = 1;
imap_check($stream_id);
foreach($options as $option) {
echo "\nTesting with option value:";
var_dump($option);
$overview = imap_fetch_overview($stream_id, $msg_uid, $option);
if ($overview) {
echo "imap_fetch_overview() returns an object\n";
}
$iterator++;
}
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,22 @@
*** Testing imap_fetch_overview() : usage variations ***
Create a temporary mailbox and add 1 msgs
.. mailbox '{%s}%s' created
Testing with option value:%string|unicode%(1) "1"
imap_fetch_overview() returns an object
Testing with option value:bool(true)
imap_fetch_overview() returns an object
Testing with option value:float(1)
imap_fetch_overview() returns an object
Testing with option value:float(1)
imap_fetch_overview() returns an object
Testing with option value:int(%d)
HipHop Warning: %a
Testing with option value:int(-%d)
HipHop Warning: %a
===DONE===
@@ -0,0 +1,24 @@
<?php
/* Prototype : array imap_fetch_overview(resource $stream_id, int $msg_no [, int $options])
* Description: Read an overview of the information in the headers
* of the given message sequence
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different resource types to imap_fetch_overview() to test behaviour
*/
echo "*** Testing imap_fetch_overview() : usage variations ***\n";
echo "\n-- File Resource opened with fopen() --\n";
var_dump($file_pointer = fopen(__FILE__, 'r+'));
var_dump(imap_fetch_overview($file_pointer, 1));
fclose($file_pointer);
echo "\n-- Directory Resource opened with opendir() --\n";
var_dump($dir_handle = opendir(dirname(__FILE__)));
var_dump(imap_fetch_overview($dir_handle, 1));
closedir($dir_handle);
?>
===DONE===
@@ -0,0 +1,12 @@
*** Testing imap_fetch_overview() : usage variations ***
-- File Resource opened with fopen() --
resource(%d) of type (stream)
HipHop Warning: %a
bool(false)
-- Directory Resource opened with opendir() --
resource(%d) of type (stream)
HipHop Warning: %a
bool(false)
===DONE===
@@ -0,0 +1,40 @@
<?php
/* Prototype : array imap_fetch_overview(resource $stream_id, int $msg_no [, int $options])
* Description: Read an overview of the information in the headers
* of the given message sequence
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different sequences/msg numbers as $msg_no argument to test behaviour
* of imap_fetch_overview()
*/
echo "*** Testing imap_fetch_overview() : usage variations ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
$stream_id = setup_test_mailbox('', 3, $mailbox, 'notSimple'); // set up temp mailbox with 3 msgs
$sequences = array (0, 4, '4', // out of range
'2', '1,3', '1, 2',
'1:3'); // pass uid without setting FT_UID option
foreach($sequences as $msg_no) {
echo "\n-- \$msg_no is $msg_no --\n";
$overview = imap_fetch_overview($stream_id, $msg_no);
if (!$overview) {
echo imap_last_error() . "\n";
} else {
foreach($overview as $ov) {
echo "\n";
displayOverviewFields($ov);
}
}
}
// clear error stack
imap_errors();
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,88 @@
*** Testing imap_fetch_overview() : usage variations ***
Create a temporary mailbox and add 3 msgs
.. mailbox '{%s}%s' created
-- $msg_no is 0 --
Sequence out of range
-- $msg_no is 4 --
Sequence out of range
-- $msg_no is 4 --
Sequence out of range
-- $msg_no is 2 --
size is %d
uid is %d
msgno is 2
recent is %d
flagged is 0
answered is 0
deleted is 0
seen is 0
draft is 0
udate is OK
-- $msg_no is 1,3 --
size is %d
uid is %d
msgno is 1
recent is %d
flagged is 0
answered is 0
deleted is 0
seen is 0
draft is 0
udate is OK
size is %d
uid is %d
msgno is 3
recent is %d
flagged is 0
answered is 0
deleted is 0
seen is 0
draft is 0
udate is OK
-- $msg_no is 1, 2 --
Syntax error in sequence
-- $msg_no is 1:3 --
size is %d
uid is %d
msgno is 1
recent is %d
flagged is 0
answered is 0
deleted is 0
seen is 0
draft is 0
udate is OK
size is %d
uid is %d
msgno is 2
recent is %d
flagged is 0
answered is 0
deleted is 0
seen is 0
draft is 0
udate is OK
size is %d
uid is %d
msgno is 3
recent is %d
flagged is 0
answered is 0
deleted is 0
seen is 0
draft is 0
udate is OK
===DONE===
@@ -0,0 +1,83 @@
<?php
/* Prototype : array imap_fetch_overview(resource $stream_id, int $msg_no [, int $options])
* Description: Read an overview of the information in the headers of the given message sequence
* Source code: ext/imap/php_imap.c
*/
/*
* Pass a multipart message to imap_fetch_overview() to test the contents of returned array
*/
echo "*** Testing imap_fetch_overview() : usage variations ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
$stream_id = setup_test_mailbox('', 0, $mailbox); // setup temp mailbox
create_multipart_message($stream_id, $mailbox);
// refresh msg numbers
imap_check($stream_id);
$msg_no = 1;
$a = imap_fetch_overview($stream_id, $msg_no);
echo "\n--> Object #1\n";
displayOverviewFields($a[0]);
/**
* Create a multipart message with subparts
*
* @param resource $imap_stream
* @param string $mailbox
*/
function create_multipart_message($imap_stream, $mailbox) {
global $users, $domain;
$envelope["from"]= "foo@anywhere.com";
$envelope["to"] = "$users[0]@$domain";
$envelope["subject"] = "Test msg 1";
$part1["type"] = TYPEMULTIPART;
$part1["subtype"] = "mixed";
$part2["type"] = TYPETEXT;
$part2["subtype"] = "plain";
$part2["description"] = "imap_mail_compose() function";
$part2["contents.data"] = "message 1:xxxxxxxxxxxxxxxxxxxxxxxxxx";
$part3["type"] = TYPETEXT;
$part3["subtype"] = "plain";
$part3["description"] = "Example";
$part3["contents.data"] = "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy";
$file_handle = fopen(__FILE__, 'r+');
$file_size = 1;
$part4["type"] = TYPEAPPLICATION;
$part4["encoding"] = ENCBASE64;
$part4["subtype"] = "octet-stream";
$part4["description"] = 'Test';
$part4['disposition.type'] = 'attachment';
$part4['disposition'] = array ('filename' => 'Test');
$part4['type.parameters'] = array('name' => 'Test');
$part4["contents.data"] = base64_encode(fread($file_handle, 1));
$body[1] = $part1;
$body[2] = $part2;
$body[3] = $part3;
$body[4] = $part4;
$msg = imap_mail_compose($envelope, $body);
if (imap_append($imap_stream, $mailbox, $msg) === false) {
echo imap_last_error() . "\n";
echo "TEST FAILED : could not append new message to mailbox '$mailbox'\n";
exit;
}
}
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,16 @@
*** Testing imap_fetch_overview() : usage variations ***
Create a temporary mailbox and add 0 msgs
.. mailbox '{%s}%s' created
--> Object #1
size is %d
uid is %d
msgno is 1
recent is %d
flagged is 0
answered is 0
deleted is 0
seen is 0
draft is 0
udate is OK
===DONE===
@@ -0,0 +1,54 @@
<?php
/* Prototype : string imap_fetchbody(resource $stream_id, int $msg_no, string $section
* [, int $options])
* Description: Get a specific body section
* Source code: ext/imap/php_imap.c
*/
echo "*** Testing imap_fetchbody() : basic functionality ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
// Initialise all required variables
// set up mailbox with one message
$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
echo "\n-- All possible arguments --\n";
foreach ($options as $key => $option) {
echo "-- Option is $key --\n";
switch ($key) {
case 'FT_UID';
$msg_uid = imap_uid($stream_id, $msg_no);
var_dump( imap_fetchbody($stream_id, $msg_uid, $section, $option) );
break;
case 'FT_PEEK';
var_dump( imap_fetchbody($stream_id, $msg_no, $section, $option) );
$overview = imap_fetch_overview($stream_id, 1);
echo "Seen Flag: ";
var_dump( $overview[0]->seen );
break;
case 'FT_INTERNAL';
var_dump( imap_fetchbody($stream_id, $msg_no, $section, $option) );
break;
}
}
// Calling imap_fetchbody() with mandatory arguments
echo "\n-- Mandatory arguments --\n";
var_dump( imap_fetchbody($stream_id, $msg_no, $section) );
$overview = imap_fetch_overview($stream_id, 1);
echo "Seen Flag: ";
var_dump( $overview[0]->seen );
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,17 @@
*** Testing imap_fetchbody() : basic functionality ***
Create a temporary mailbox and add 1 msgs
.. mailbox '{%s}%s' created
-- All possible arguments --
-- Option is FT_UID --
%unicode|string%(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
-- Option is FT_PEEK --
%unicode|string%(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
Seen Flag: int(%d)
-- Option is FT_INTERNAL --
%unicode|string%(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
-- Mandatory arguments --
%unicode|string%(36) "message 2:yyyyyyyyyyyyyyyyyyyyyyyyyy"
Seen Flag: int(%d)
===DONE===
@@ -0,0 +1,33 @@
<?php
/* Prototype :string imap_fetchbody(resource $stream_id, int $msg_no, string $section
* [, int $options])
* Description: Get a specific body section
* Source code: ext/imap/php_imap.c
*/
/*
* Pass an incorrect number of arguments to imap_fetchbody() to test behaviour
*/
echo "*** Testing imap_fetchbody() : error conditions ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
//Test imap_fetchbody with one more than the expected number of arguments
echo "\n-- Testing imap_fetchbody() function with more than expected no. of arguments --\n";
$stream_id = setup_test_mailbox('', 1); // set up temp mailbox with 1 simple msg
$msg_no = 1;
$section = '1';
$options = FT_PEEK;
$extra_arg = 10;
var_dump( imap_fetchbody($stream_id, $msg_no, $section, $options, $extra_arg) );
// Testing imap_fetchbody with one less than the expected number of arguments
echo "\n-- Testing imap_fetchbody() function with less than expected no. of arguments --\n";
var_dump( imap_fetchbody($stream_id, $msg_no) );
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,12 @@
*** Testing imap_fetchbody() : error conditions ***
-- Testing imap_fetchbody() function with more than expected no. of arguments --
Create a temporary mailbox and add 1 msgs
.. mailbox '{%s}%s' created
HipHop Warning: %a
NULL
-- Testing imap_fetchbody() function with less than expected no. of arguments --
HipHop Warning: %a
NULL
===DONE===
@@ -0,0 +1,89 @@
<?php
/* Prototype : string imap_fetchbody(resource $stream_id, int $msg_no, string $section
* [, int $options])
* Description: Get a specific body section
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different data types as $stream_id argument to test behaviour of imap_fetchbody()
*/
echo "*** Testing imap_fetchbody() : usage variations ***\n";
// Initialise function arguments not being substituted
$msg_no = 1;
$section = '2';
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a class
class classA
{
public function __toString() {
return "Class A object";
}
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// unexpected values to be passed to $stream_id argument
$inputs = array(
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
/*12*/ true,
false,
TRUE,
FALSE,
// empty data
/*16*/ "",
'',
array(),
// string data
/*19*/ "string",
'string',
$heredoc,
// object data
/*22*/ new classA(),
// undefined data
/*23*/ @$undefined_var,
// unset data
/*24*/ @$unset_var,
);
// loop through each element of $inputs to check the behavior of imap_fetchbody()
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Iteration $iterator --\n";
var_dump( imap_fetchbody($input, $msg_no, $section) );
$iterator++;
}
?>
===DONE===
@@ -0,0 +1,98 @@
*** Testing imap_fetchbody() : usage variations ***
-- Iteration 1 --
HipHop Warning: %a
NULL
-- Iteration 2 --
HipHop Warning: %a
NULL
-- Iteration 3 --
HipHop Warning: %a
NULL
-- Iteration 4 --
HipHop Warning: %a
NULL
-- Iteration 5 --
HipHop Warning: %a
NULL
-- Iteration 6 --
HipHop Warning: %a
NULL
-- Iteration 7 --
HipHop Warning: %a
NULL
-- Iteration 8 --
HipHop Warning: %a
NULL
-- Iteration 9 --
HipHop Warning: %a
NULL
-- Iteration 10 --
HipHop Warning: %a
NULL
-- Iteration 11 --
HipHop Warning: %a
NULL
-- Iteration 12 --
HipHop Warning: %a
NULL
-- Iteration 13 --
HipHop Warning: %a
NULL
-- Iteration 14 --
HipHop Warning: %a
NULL
-- Iteration 15 --
HipHop Warning: %a
NULL
-- Iteration 16 --
HipHop Warning: %a
NULL
-- Iteration 17 --
HipHop Warning: %a
NULL
-- Iteration 18 --
HipHop Warning: %a
NULL
-- Iteration 19 --
HipHop Warning: %a
NULL
-- Iteration 20 --
HipHop Warning: %a
NULL
-- Iteration 21 --
HipHop Warning: %a
NULL
-- Iteration 22 --
HipHop Warning: %a
NULL
-- Iteration 23 --
HipHop Warning: %a
NULL
-- Iteration 24 --
HipHop Warning: %a
NULL
===DONE===
@@ -0,0 +1,93 @@
<?php
/* Prototype : string imap_fetchbody(resource $stream_id, int $msg_no, string $section
* [, int $options])
* Description: Get a specific body section
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different data types as $msg_no argument to test behaviour of imap_fetchbody()
*/
echo "*** Testing imap_fetchbody() : usage variations ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
// Initialise function arguments not being substituted
$stream_id = setup_test_mailbox('', 1); // set up temp mailbox with 1 simple msg
$section = '1';
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a class
class classA
{
public function __toString() {
return "Class A object";
}
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// unexpected values to be passed to $msg_no argument
$inputs = array(
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
/*12*/ true,
false,
TRUE,
FALSE,
// empty data
/*16*/ "",
'',
array(),
// string data
/*19*/ "string",
'string',
$heredoc,
// object data
/*22*/ new classA(),
// undefined data
/*23*/ @$undefined_var,
// unset data
/*24*/ @$unset_var,
);
// loop through each element of $inputs to check the behavior of imap_fetchbody()
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Iteration $iterator --\n";
var_dump( imap_fetchbody($stream_id, $input, $section) );
$iterator++;
};
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,97 @@
*** Testing imap_fetchbody() : usage variations ***
Create a temporary mailbox and add 1 msgs
.. mailbox '{%s}%s' created
-- Iteration 1 --
HipHop Warning: %a
bool(false)
-- Iteration 2 --
%unicode|string%(%d) "1: this is a test message, please ignore%a"
-- Iteration 3 --
HipHop Warning: %a
bool(false)
-- Iteration 4 --
HipHop Warning: %a
bool(false)
-- Iteration 5 --
HipHop Warning: %a
bool(false)
-- Iteration 6 --
HipHop Warning: %a
bool(false)
-- Iteration 7 --
HipHop Warning: %a
bool(false)
-- Iteration 8 --
HipHop Warning: %a
bool(false)
-- Iteration 9 --
HipHop Warning: %a
bool(false)
-- Iteration 10 --
HipHop Warning: %a
bool(false)
-- Iteration 11 --
HipHop Warning: %a
bool(false)
-- Iteration 12 --
%unicode|string%(%d) "1: this is a test message, please ignore%a"
-- Iteration 13 --
HipHop Warning: %a
bool(false)
-- Iteration 14 --
%unicode|string%(%d) "1: this is a test message, please ignore%a"
-- Iteration 15 --
HipHop Warning: %a
bool(false)
-- Iteration 16 --
HipHop Warning: %a
NULL
-- Iteration 17 --
HipHop Warning: %a
NULL
-- Iteration 18 --
HipHop Warning: %a
NULL
-- Iteration 19 --
HipHop Warning: %a
NULL
-- Iteration 20 --
HipHop Warning: %a
NULL
-- Iteration 21 --
HipHop Warning: %a
NULL
-- Iteration 22 --
HipHop Warning: %a
NULL
-- Iteration 23 --
HipHop Warning: %a
bool(false)
-- Iteration 24 --
HipHop Warning: %a
bool(false)
===DONE===
@@ -0,0 +1,93 @@
<?php
/* Prototype : string imap_fetchbody(resource $stream_id, int $msg_no, string $section
* [, int $options])
* Description: Get a specific body section
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different data types as $section argument to test behaviour of imap_fetchbody()
*/
echo "*** Testing imap_fetchbody() : usage variations ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
// Initialise function arguments not being substituted
$stream_id = setup_test_mailbox('', 1); // set up temp mailbox with 1 simple msg
$msg_no = 1;
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a class
class classA
{
public function __toString() {
return "Class A object";
}
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// unexpected values to be passed to $section argument
$inputs = array(
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
/*12*/ true,
false,
TRUE,
FALSE,
// empty data
/*16*/ "",
'',
array(),
// string data
/*19*/ "string",
'string',
$heredoc,
// object data
/*22*/ new classA(),
// undefined data
/*23*/ @$undefined_var,
// unset data
/*24*/ @$unset_var,
);
// loop through each element of $inputs to check the behavior of imap_fetchbody()
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Iteration $iterator --\n";
var_dump( imap_fetchbody($stream_id, $msg_no, $input) );
$iterator++;
};
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,113 @@
*** Testing imap_fetchbody() : usage variations ***
Create a temporary mailbox and add 1 msgs
.. mailbox '%s.phpttest' created
-- Iteration 1 --
string(71) "From: %s
To: %s
Subject: test1
"
-- Iteration 2 --
%unicode|string%(%d) "1: this is a test message, please ignore%a"
-- Iteration 3 --
%unicode|string%(0) ""
-- Iteration 4 --
%unicode|string%(0) ""
-- Iteration 5 --
%unicode|string%(0) ""
-- Iteration 6 --
%unicode|string%(0) ""
-- Iteration 7 --
%unicode|string%(0) ""
-- Iteration 8 --
%unicode|string%(0) ""
-- Iteration 9 --
%unicode|string%(0) ""
-- Iteration 10 --
%unicode|string%(%d) "From: %s
To: %s
Subject: test1
1: this is a test message, please ignore%a"
-- Iteration 11 --
%unicode|string%(%d) "From: %s
To: %s
Subject: test1
1: this is a test message, please ignore%a"
-- Iteration 12 --
%unicode|string%(%d) "1: this is a test message, please ignore%a"
-- Iteration 13 --
%unicode|string%(%d) "From: %s
To: %s
Subject: test1
1: this is a test message, please ignore%a"
-- Iteration 14 --
%unicode|string%(%d) "1: this is a test message, please ignore%a"
-- Iteration 15 --
%unicode|string%(%d) "From: %s
To: %s
Subject: test1
1: this is a test message, please ignore%a"
-- Iteration 16 --
%unicode|string%(%d) "From: %s
To: %s
Subject: test1
1: this is a test message, please ignore%a"
-- Iteration 17 --
%unicode|string%(%d) "From: %s
To: %s
Subject: test1
1: this is a test message, please ignore%a"
-- Iteration 18 --
HipHop Warning: %a
NULL
-- Iteration 19 --
%unicode|string%(0) ""
-- Iteration 20 --
%unicode|string%(0) ""
-- Iteration 21 --
%unicode|string%(0) ""
-- Iteration 22 --
%unicode|string%(0) ""
-- Iteration 23 --
%unicode|string%(%d) "From: %s
To: %s
Subject: test1
1: this is a test message, please ignore%a"
-- Iteration 24 --
%unicode|string%(%d) "From: %s
To: %s
Subject: test1
1: this is a test message, please ignore%a"
===DONE===
@@ -0,0 +1,43 @@
<?php
/* Prototype : string imap_fetchbody(resource $stream_id, int $msg_no, string $section [, int $options])
* Description: Get a specific body section
* Source code: ext/imap/php_imap.c
*/
/*
* Test if FT_UID is set by passing the following as $options argument to imap_fetchbody():
* 1. values that equate to 1
* 2. Minimum and maximum PHP values
*/
echo "*** Testing imap_fetchbody() : usage variations ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
// Initialise required variables
$stream_id = setup_test_mailbox('', 1); // set up temporary mailbox with one simple message
$msg_no = 1;
$msg_uid = imap_uid($stream_id, $msg_no);
$section = 1;
//Note: the first four values are valid as they will all be cast to 1L.
$options = array ('1', true,
1.000000000000001, 0.00001e5,
PHP_INT_MAX, -PHP_INT_MAX);
// iterate over each element of $options array to test whether FT_UID is set
$iterator = 1;
imap_check($stream_id);
foreach($options as $option) {
echo "\n-- Iteration $iterator --\n";
if(is_string(imap_fetchbody($stream_id, $msg_uid, $section, $option))) {
echo "FT_UID valid\n";
} else {
echo "FT_UID not valid\n";
}
$iterator++;
}
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,24 @@
*** Testing imap_fetchbody() : usage variations ***
Create a temporary mailbox and add 1 msgs
.. mailbox '{%s}%s' created
-- Iteration 1 --
FT_UID valid
-- Iteration 2 --
FT_UID valid
-- Iteration 3 --
FT_UID valid
-- Iteration 4 --
FT_UID valid
-- Iteration 5 --
HipHop Warning: %a
FT_UID not valid
-- Iteration 6 --
HipHop Warning: %a
FT_UID not valid
===DONE===
@@ -0,0 +1,24 @@
<?php
/* Prototype : string imap_fetchbody(resource $stream_id, int $msg_no, string $section
* [, int options])
* Description: Get a specific body section
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different resource types to imap_fetchbody() to test behaviour
*/
echo "*** Testing imap_fetchbody() : usage variations ***\n";
echo "\n-- File Resource opened with fopen() --\n";
var_dump($file_pointer = fopen(__FILE__, 'r+'));
var_dump(imap_fetchbody($file_pointer, 1));
fclose($file_pointer);
echo "\n-- Directory Resource opened with opendir() --\n";
var_dump($dir_handle = opendir(dirname(__FILE__)));
var_dump(imap_fetchbody($dir_handle, 1));
closedir($dir_handle);
?>
===DONE===
@@ -0,0 +1,12 @@
*** Testing imap_fetchbody() : usage variations ***
-- File Resource opened with fopen() --
resource(5) of type (stream)
HipHop Warning: %a
NULL
-- Directory Resource opened with opendir() --
resource(6) of type (stream)
HipHop Warning: %a
NULL
===DONE===
@@ -0,0 +1,34 @@
<?php
/* Prototype : string imap_fetchbody(resource $stream_id, int $msg_no, string $section [, int $options])
* Description: Get a specific body section
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different integers, strings, msg sequences and msg UIDs as $msg_no argument
* to test behaviour of imap_fetchbody()
*/
echo "*** Testing imap_fetchbody() : usage variations ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
//Initialise required variables
$stream_id = setup_test_mailbox('', 3); // set up temp mailbox with simple msgs
$section = 1;
$sequences = array (0, 4, // out of range
'1,3', '1:3', // message sequences instead of numbers
);
foreach($sequences as $msg_no) {
echo "\n-- \$msg_no is $msg_no --\n";
var_dump($overview = imap_fetchbody($stream_id, $msg_no, $section));
if (!$overview) {
echo imap_last_error() . "\n";
}
}
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,22 @@
*** Testing imap_fetchbody() : usage variations ***
Create a temporary mailbox and add 3 msgs
.. mailbox '{%s}%s' created
-- $msg_no is 0 --
HipHop Warning: %a
bool(false)
-- $msg_no is 4 --
HipHop Warning: %a
bool(false)
-- $msg_no is 1,3 --
HipHop Notice: %a
%unicode|string%(%d) "1: this is a test message, please ignore%a"
-- $msg_no is 1:3 --
HipHop Notice: %a
%unicode|string%(%d) "1: this is a test message, please ignore%a"
===DONE===
@@ -0,0 +1,34 @@
<?php
/* Prototype : string imap_fetchheader(resource $stream_id, int $msg_no [, int $options])
* Description: Get the full unfiltered header for a message
* Source code: ext/imap/php_imap.c
*/
echo "*** Testing imap_fetchheader() : basic functionality ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
// Initialise all required variables
$stream_id = setup_test_mailbox('', 1, $mailbox, 'multiPart'); // setup temp mailbox with 1 msg
$msg_no = 1;
$options = array('FT_UID' => FT_UID, 'FT_INTERNAL' => FT_INTERNAL,
'FT_PREFETCHTEXT' => FT_PREFETCHTEXT);
// Calling imap_fetchheader() with all possible arguments
echo "\n-- All possible arguments --\n";
foreach ($options as $key => $option) {
echo "-- Option is $key --\n";
if ($key == 'FT_UID') {
$msg_uid = imap_uid($stream_id, $msg_no);
var_dump(imap_fetchheader($stream_id, $msg_uid, $option));
} else {
var_dump(imap_fetchheader($stream_id, $msg_no, $option));
}
}
// Calling imap_fetchheader() with mandatory arguments
echo "\n-- Mandatory arguments --\n";
var_dump( imap_fetchheader($stream_id, $msg_no) );
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,39 @@
*** Testing imap_fetchheader() : basic functionality ***
Create a temporary mailbox and add 1 msgs
.. mailbox '%s.phpttest' created
-- All possible arguments --
-- Option is FT_UID --
string(%d) "From: foo@anywhere.com
Subject: Test msg 1
To: %s
MIME-Version: 1.0
Content-Type: %s; %s
"
-- Option is FT_INTERNAL --
string(%d) "From: foo@anywhere.com
Subject: Test msg 1
To: %s
MIME-Version: 1.0
Content-Type: %s; %s
"
-- Option is FT_PREFETCHTEXT --
string(%d) "From: foo@anywhere.com
Subject: Test msg 1
To: %s
MIME-Version: 1.0
Content-Type: %s; %s
"
-- Mandatory arguments --
string(%d) "From: foo@anywhere.com
Subject: Test msg 1
To: %s
MIME-Version: 1.0
Content-Type: %s; %s
"
===DONE===
@@ -0,0 +1,29 @@
<?php
/* Prototype : string imap_fetchheader(resource $stream_id, int $msg_no [, int $options])
* Description: Get the full unfiltered header for a message
* Source code: ext/imap/php_imap.c
*/
/*
* Pass an incorrect number of arguments to imap_fetchheader() to test behaviour
*/
echo "*** Testing imap_fetchheader() : error conditions ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
//Test imap_fetchheader with one more than the expected number of arguments
echo "\n-- Testing imap_fetchheader() function with more than expected no. of arguments --\n";
$stream_id = imap_open($server, $username, $password);
$msg_no = 10;
$options = 10;
$extra_arg = 10;
var_dump( imap_fetchheader($stream_id, $msg_no, $options, $extra_arg) );
// Testing imap_fetchheader with one less than the expected number of arguments
echo "\n-- Testing imap_fetchheader() function with less than expected no. of arguments --\n";
var_dump( imap_fetchheader($stream_id) );
imap_close($stream_id);
?>
===DONE===
@@ -0,0 +1,10 @@
*** Testing imap_fetchheader() : error conditions ***
-- Testing imap_fetchheader() function with more than expected no. of arguments --
HipHop Warning: %a
NULL
-- Testing imap_fetchheader() function with less than expected no. of arguments --
HipHop Warning: %a
NULL
===DONE===
@@ -0,0 +1,100 @@
<?php
/* Prototype : string imap_fetchheader(resource $stream_id, int $msg_no [, int $options])
* Description: Get the full unfiltered header for a message
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different data types as $stream_id argument to test behaviour of imap_fetchheader()
*/
echo "*** Testing imap_fetchheader() : usage variations ***\n";
// Initialise function arguments not being substituted
$msg_no = 1;
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a class
class classA
{
public function __toString() {
return "Class A object";
}
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// get different types of array
$index_array = array (1, 2, 3);
$assoc_array = array ('one' => 1, 'two' => 2);
// get a resource variable
$fp = fopen(__FILE__, "r");
// unexpected values to be passed to $stream_id argument
$inputs = array(
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
/*12*/ true,
false,
TRUE,
FALSE,
// empty data
/*16*/ "",
'',
// string data
/*18*/ "string",
'string',
$heredoc,
// array data
/*21*/ array(),
$index_array,
$assoc_array,
array('foo', $index_array, $assoc_array),
// object data
/*25*/ new classA(),
// undefined data
/*26*/ @$undefined_var,
// unset data
/*27*/ @$unset_var,
);
// loop through each element of $inputs to check the behavior of imap_fetchheader()
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Iteration $iterator --\n";
var_dump( imap_fetchheader($input, $msg_no) );
$iterator++;
};
?>
===DONE===
@@ -0,0 +1,110 @@
*** Testing imap_fetchheader() : usage variations ***
-- Iteration 1 --
HipHop Warning: %a
NULL
-- Iteration 2 --
HipHop Warning: %a
NULL
-- Iteration 3 --
HipHop Warning: %a
NULL
-- Iteration 4 --
HipHop Warning: %a
NULL
-- Iteration 5 --
HipHop Warning: %a
NULL
-- Iteration 6 --
HipHop Warning: %a
NULL
-- Iteration 7 --
HipHop Warning: %a
NULL
-- Iteration 8 --
HipHop Warning: %a
NULL
-- Iteration 9 --
HipHop Warning: %a
NULL
-- Iteration 10 --
HipHop Warning: %a
NULL
-- Iteration 11 --
HipHop Warning: %a
NULL
-- Iteration 12 --
HipHop Warning: %a
NULL
-- Iteration 13 --
HipHop Warning: %a
NULL
-- Iteration 14 --
HipHop Warning: %a
NULL
-- Iteration 15 --
HipHop Warning: %a
NULL
-- Iteration 16 --
HipHop Warning: %a
NULL
-- Iteration 17 --
HipHop Warning: %a
NULL
-- Iteration 18 --
HipHop Warning: %a
NULL
-- Iteration 19 --
HipHop Warning: %a
NULL
-- Iteration 20 --
HipHop Warning: %a
NULL
-- Iteration 21 --
HipHop Warning: %a
NULL
-- Iteration 22 --
HipHop Warning: %a
NULL
-- Iteration 23 --
HipHop Warning: %a
NULL
-- Iteration 24 --
HipHop Warning: %a
NULL
-- Iteration 25 --
HipHop Warning: %a
NULL
-- Iteration 26 --
HipHop Warning: %a
NULL
-- Iteration 27 --
HipHop Warning: %a
NULL
===DONE===
@@ -0,0 +1,108 @@
<?php
/* Prototype : string imap_fetchheader(resource $stream_id, int $msg_no [, int $options])
* Description: Get the full unfiltered header for a message
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different data types as $msg_no argument to test behaviour of imap_fetchheader()
*/
echo "*** Testing imap_fetchheader() : usage variations ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
// Initialise function arguments not being substituted
$stream_id = setup_test_mailbox('', 1, $mailbox, 'notSimple'); // set up temp mailbox with 1 msg
//get an unset variable
$unset_var = 10;
unset ($unset_var);
// get a class
class classA
{
public function __toString() {
return "Class A object";
}
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
$index_array = array (1, 2, 3);
$assoc_array = array ('one' => 1, 'two' => 2);
// get a resource variable
$fp = fopen(__FILE__, "r");
// unexpected values to be passed to $msg_no argument
$inputs = array(
// int data
/*1*/ 0,
1,
12345,
-2345,
// float data
/*5*/ 10.5,
-10.5,
12.3456789000e10,
12.3456789000E-10,
.5,
// null data
/*10*/ NULL,
null,
// boolean data
/*12*/ true,
false,
TRUE,
FALSE,
// empty data
/*16*/ "",
'',
// string data
/*18*/ "string",
'string',
$heredoc,
// array data
/*21*/ array(),
$index_array,
$assoc_array,
array('foo', $index_array, $assoc_array),
// object data
/*25*/ new classA(),
// undefined data
/*26*/ @$undefined_var,
// unset data
/*27*/ @$unset_var,
// resource variable
/*28*/ $fp
);
// loop through each element of $inputs to check the behavior of imap_fetchheader()
$iterator = 1;
foreach($inputs as $input) {
echo "\n-- Iteration $iterator --\n";
var_dump( imap_fetchheader($stream_id, $input) );
$iterator++;
};
fclose($fp);
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
===DONE===
@@ -0,0 +1,131 @@
*** Testing imap_fetchheader() : usage variations ***
Create a temporary mailbox and add 1 msgs
.. mailbox '{%s}%s' created
-- Iteration 1 --
HipHop Warning: %a
bool(false)
-- Iteration 2 --
%unicode|string%(%d) "From: foo@anywhere.com
Subject: Test msg 1
To: %s
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="%s"
"
-- Iteration 3 --
HipHop Warning: %a
bool(false)
-- Iteration 4 --
HipHop Warning: %a
bool(false)
-- Iteration 5 --
HipHop Warning: %a
bool(false)
-- Iteration 6 --
HipHop Warning: %a
bool(false)
-- Iteration 7 --
HipHop Warning: %a
bool(false)
-- Iteration 8 --
HipHop Warning: %a
bool(false)
-- Iteration 9 --
HipHop Warning: %a
bool(false)
-- Iteration 10 --
HipHop Warning: %a
bool(false)
-- Iteration 11 --
HipHop Warning: %a
bool(false)
-- Iteration 12 --
%unicode|string%(%d) "From: foo@anywhere.com
Subject: Test msg 1
To: %s
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="%s"
"
-- Iteration 13 --
HipHop Warning: %a
bool(false)
-- Iteration 14 --
%unicode|string%(%d) "From: foo@anywhere.com
Subject: Test msg 1
To: %s
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="%s"
"
-- Iteration 15 --
HipHop Warning: %a
bool(false)
-- Iteration 16 --
HipHop Warning: %a
NULL
-- Iteration 17 --
HipHop Warning: %a
NULL
-- Iteration 18 --
HipHop Warning: %a
NULL
-- Iteration 19 --
HipHop Warning: %a
NULL
-- Iteration 20 --
HipHop Warning: %a
NULL
-- Iteration 21 --
HipHop Warning: %a
NULL
-- Iteration 22 --
HipHop Warning: %a
NULL
-- Iteration 23 --
HipHop Warning: %a
NULL
-- Iteration 24 --
HipHop Warning: %a
NULL
-- Iteration 25 --
HipHop Warning: %a
NULL
-- Iteration 26 --
HipHop Warning: %a
bool(false)
-- Iteration 27 --
HipHop Warning: %a
bool(false)
-- Iteration 28 --
HipHop Warning: %a
NULL
===DONE===
@@ -0,0 +1,41 @@
<?php
/* Prototype : string imap_fetchheader(resource $stream_id, int $msg_no [, int $options])
* Description: Get the full unfiltered header for a message
* Source code: ext/imap/php_imap.c
*/
/*
* Test if FT_UID is set by passing the following as $options argument to imap_fetchheader():
* 1. values that equate to 1
* 2. Minimum and maximum PHP values
*/
echo "*** Testing imap_fetchheader() : usage variations ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
// Initialise required variables
$stream_id = setup_test_mailbox('', 1); // set up temporary mailbox with one simple message
$msg_no = 1;
$msg_uid = imap_uid($stream_id, $msg_no);
$options = array ('1', true,
1.000000000000001, 0.00001e5,
PHP_INT_MAX, -PHP_INT_MAX);
// iterate over each element of $options array to test whether FT_UID is set
$iterator = 1;
imap_check($stream_id);
foreach($options as $option) {
echo "\n-- Iteration $iterator --\n";
if(is_string(imap_fetchheader($stream_id, $msg_uid, $option))) {
echo "FT_UID valid\n";
} else {
echo "FT_UID not valid\n";
}
$iterator++;
}
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,24 @@
*** Testing imap_fetchheader() : usage variations ***
Create a temporary mailbox and add 1 msgs
.. mailbox '{%s}%s' created
-- Iteration 1 --
FT_UID valid
-- Iteration 2 --
FT_UID valid
-- Iteration 3 --
FT_UID valid
-- Iteration 4 --
FT_UID valid
-- Iteration 5 --
HipHop Warning: %a
FT_UID not valid
-- Iteration 6 --
HipHop Warning: %a
FT_UID not valid
===DONE===
@@ -0,0 +1,23 @@
<?php
/* Prototype : string imap_fetchheader(resource $stream_id, int $msg_no [, int $options])
* Description: Get the full unfiltered header for a message
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different types of resources to imap_fetchheader() to test behaviour
*/
echo "*** Testing imap_fetchheader() : usage variations ***\n";
echo "\n-- File Resource opened with fopen() --\n";
var_dump($file_pointer = fopen(__FILE__, 'r+'));
var_dump(imap_fetchheader($file_pointer, 1));
fclose($file_pointer);
echo "\n-- Directory Resource opened with opendir() --\n";
var_dump($dir_handle = opendir(dirname(__FILE__)));
var_dump(imap_fetchheader($dir_handle, 1));
closedir($dir_handle);
?>
===DONE===
@@ -0,0 +1,12 @@
*** Testing imap_fetchheader() : usage variations ***
-- File Resource opened with fopen() --
resource(%d) of type (stream)
HipHop Warning: %a
bool(false)
-- Directory Resource opened with opendir() --
resource(%d) of type (stream)
HipHop Warning: %a
bool(false)
===DONE===
@@ -0,0 +1,35 @@
<?php
/* Prototype : string imap_fetchheader(resource $stream_id, int $msg_no [, int $options])
* Description: Get the full unfiltered header for a message
* Source code: ext/imap/php_imap.c
*/
/*
* Pass different integers and strings as $msg_no argument
* to test behaviour of imap_fetchheader()
*/
echo "*** Testing imap_fetchheader() : usage variations ***\n";
require_once(dirname(__FILE__).'/imap_include.inc');
$stream_id = setup_test_mailbox('', 3, $mailbox, 'notSimple'); // set up temp mailbox with 3 msgs
$sequences = array (0, 4, // out of range
'1,3', '1:3', // message sequences instead of numbers
);
foreach($sequences as $msg_no) {
echo "\n-- \$msg_no is $msg_no --\n";
var_dump($overview = imap_fetchheader($stream_id, $msg_no));
if (!$overview) {
echo imap_last_error() . "\n";
}
}
// clear error stack
imap_errors();
?>
===DONE===<?php
require_once(dirname(__FILE__).'/clean.inc');
?>
@@ -0,0 +1,34 @@
*** Testing imap_fetchheader() : usage variations ***
Create a temporary mailbox and add 3 msgs
.. mailbox '{%s}%s' created
-- $msg_no is 0 --
HipHop Warning: %a
bool(false)
-- $msg_no is 4 --
HipHop Warning: %a
bool(false)
-- $msg_no is 1,3 --
HipHop Notice: %a
%unicode|string%(%d) "From: foo@anywhere.com
Subject: Test msg 1
To: %s
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="%s"
"
-- $msg_no is 1:3 --
HipHop Notice: %a
%unicode|string%(%d) "From: foo@anywhere.com
Subject: Test msg 1
To: %s
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="%s"
"
===DONE===
@@ -0,0 +1,33 @@
<?php
echo "Checking with no parameters\n";
imap_fetchstructure();
echo "Checking with incorrect parameter type\n";
imap_fetchstructure('');
imap_fetchstructure(false);
require_once(dirname(__FILE__).'/imap_include.inc');
$stream_id = setup_test_mailbox('', 1);
imap_fetchstructure($stream_id);
imap_fetchstructure($stream_id,0);
$z = imap_fetchstructure($stream_id,1);
$fields = array('type','encoding','ifsubtype','subtype',
'ifdescription','lines','bytes','parameters');
foreach ($fields as $key) {
var_dump(isset($z->$key));
}
var_dump($z->type);
var_dump($z->encoding);
var_dump($z->bytes);
var_dump($z->lines);
var_dump(is_object($z->parameters));
imap_close($stream_id);
?><?php
require_once('clean.inc');
?>
@@ -0,0 +1,21 @@
Checking with no parameters
HipHop Warning: %a
Checking with incorrect parameter type
HipHop Warning: %a
HipHop Warning: %a
Create a temporary mailbox and add 1 msgs
.. mailbox '{%s}%s' created
HipHop Warning: %a
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
int(%d)
int(%d)
int(%d)
int(%d)
bool(true)
@@ -0,0 +1,14 @@
<?php
echo "Checking with no parameters\n";
imap_gc();
echo "Checking with incorrect parameter type\n";
imap_gc('', false);
imap_gc(false, false);
require_once(dirname(__FILE__).'/imap_include.inc');
$stream_id = imap_open($default_mailbox, $username, $password) or
die("Cannot connect to mailbox $default_mailbox: " . imap_last_error());
imap_gc($stream_id, -1);
?>
@@ -0,0 +1,6 @@
Checking with no parameters
HipHop Warning: %a
Checking with incorrect parameter type
HipHop Warning: %a
HipHop Warning: %a
HipHop Warning: %a

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais