diff options
author | Zoe Slattery <zoe@php.net> | 2008-12-08 19:10:45 +0000 |
---|---|---|
committer | Zoe Slattery <zoe@php.net> | 2008-12-08 19:10:45 +0000 |
commit | 30286f90b36f55ea344b2263f7dd50e035a3e80d (patch) | |
tree | 7e82d543b8aa79b27fbc42608ca696676fcf56fb | |
parent | 8f245aaf941867f252250ebb230a6b940c6c8eae (diff) | |
download | php-git-30286f90b36f55ea344b2263f7dd50e035a3e80d.tar.gz |
tests for imap_fetch_overview
-rw-r--r-- | ext/imap/tests/imap_fetch_overview_basic.phpt | 118 | ||||
-rw-r--r-- | ext/imap/tests/imap_fetch_overview_error.phpt | 54 | ||||
-rw-r--r-- | ext/imap/tests/imap_fetch_overview_variation1.phpt | 221 | ||||
-rw-r--r-- | ext/imap/tests/imap_fetch_overview_variation2.phpt | 245 | ||||
-rw-r--r-- | ext/imap/tests/imap_fetch_overview_variation3.phpt | 80 | ||||
-rw-r--r-- | ext/imap/tests/imap_fetch_overview_variation4.phpt | 46 | ||||
-rw-r--r-- | ext/imap/tests/imap_fetch_overview_variation5.phpt | 149 | ||||
-rw-r--r-- | ext/imap/tests/imap_fetch_overview_variation6.phpt | 125 |
8 files changed, 1038 insertions, 0 deletions
diff --git a/ext/imap/tests/imap_fetch_overview_basic.phpt b/ext/imap/tests/imap_fetch_overview_basic.phpt new file mode 100644 index 0000000000..80d5c69f1d --- /dev/null +++ b/ext/imap/tests/imap_fetch_overview_basic.phpt @@ -0,0 +1,118 @@ +--TEST-- +Test imap_fetch_overview() function : basic functionality +--SKIPIF-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?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; + +//Set mandatory response fields +$mandatoryFields = array( + 'size', + 'uid', + 'msgno', + 'recent', + 'flagged', + 'answered', + 'deleted', + 'seen', + 'draft', + ); + +// 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"; +foreach ($mandatoryFields as $mf) +{ + $z = $a[0]->$mf; + echo "$mf is $z\n"; +} + +// 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"; +foreach ($mandatoryFields as $mf) +{ + $z = $a[0]->$mf; + echo "$mf is $z\n"; +} + +//Second object in array +echo "\n--> Object #2\n"; +foreach ($mandatoryFields as $mf) +{ + $z = $a[1]->$mf; + echo "$mf is $z\n"; +} + +imap_close($stream_id); + +?> +===DONE=== +--CLEAN-- +<?php +require_once(dirname(__FILE__).'/clean.inc'); +?> +--EXPECTF-- +*** Testing imap_fetch_overview() : basic functionality *** +Create a temporary mailbox and add 2 msgs +.. mailbox '{localhost/norsh}INBOX.phpttest' 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 + +-- 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 + +--> 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 +===DONE=== diff --git a/ext/imap/tests/imap_fetch_overview_error.phpt b/ext/imap/tests/imap_fetch_overview_error.phpt new file mode 100644 index 0000000000..2fc0f343c3 --- /dev/null +++ b/ext/imap/tests/imap_fetch_overview_error.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test imap_fetch_overview() function : error conditions - incorrect number of args +--SKIPIF-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?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=== +--CLEAN-- +<?php +require_once(dirname(__FILE__).'/clean.inc'); +?> +--EXPECTF-- +*** 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 '{localhost/norsh}INBOX.phpttest' created + +Warning: imap_fetch_overview() expects at most 3 parameters, 4 given in %s on line %d +NULL + +-- Testing imap_fetch_overview() function with less than expected no. of arguments -- + +Warning: imap_fetch_overview() expects at least 2 parameters, 1 given in %s on line %d +NULL +===DONE=== diff --git a/ext/imap/tests/imap_fetch_overview_variation1.phpt b/ext/imap/tests/imap_fetch_overview_variation1.phpt new file mode 100644 index 0000000000..150c555617 --- /dev/null +++ b/ext/imap/tests/imap_fetch_overview_variation1.phpt @@ -0,0 +1,221 @@ +--TEST-- +Test imap_fetch_overview() function : usage variations - diff data types as $stream_id arg +--SKIPIF-- +<?php +extension_loaded('imap') or die('skip imap extension not available in this build'); +?> +--FILE-- +<?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=== +--EXPECTF-- +*** Testing imap_fetch_overview() : usage variations *** + +-- Testing with first argument value: int(0) + +Warning: imap_fetch_overview() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +-- Testing with first argument value: int(1) + +Warning: imap_fetch_overview() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +-- Testing with first argument value: int(12345) + +Warning: imap_fetch_overview() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +-- Testing with first argument value: int(-2345) + +Warning: imap_fetch_overview() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +-- Testing with first argument value: float(10.5) + +Warning: imap_fetch_overview() expects parameter 1 to be resource, double given in %s on line %d +NULL + +-- Testing with first argument value: float(-10.5) + +Warning: imap_fetch_overview() expects parameter 1 to be resource, double given in %s on line %d +NULL + +-- Testing with first argument value: float(123456789000) + +Warning: imap_fetch_overview() expects parameter 1 to be resource, double given in %s on line %d +NULL + +-- Testing with first argument value: float(1.23456789E-9) + +Warning: imap_fetch_overview() expects parameter 1 to be resource, double given in %s on line %d +NULL + +-- Testing with first argument value: float(0.5) + +Warning: imap_fetch_overview() expects parameter 1 to be resource, double given in %s on line %d +NULL + +-- Testing with first argument value: NULL + +Warning: imap_fetch_overview() expects parameter 1 to be resource, null given in %s on line %d +NULL + +-- Testing with first argument value: NULL + +Warning: imap_fetch_overview() expects parameter 1 to be resource, null given in %s on line %d +NULL + +-- Testing with first argument value: bool(true) + +Warning: imap_fetch_overview() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +-- Testing with first argument value: bool(false) + +Warning: imap_fetch_overview() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +-- Testing with first argument value: bool(true) + +Warning: imap_fetch_overview() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +-- Testing with first argument value: bool(false) + +Warning: imap_fetch_overview() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +-- Testing with first argument value: %string|unicode%(0) "" + +Warning: imap_fetch_overview() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d +NULL + +-- Testing with first argument value: %string|unicode%(0) "" + +Warning: imap_fetch_overview() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d +NULL + +-- Testing with first argument value: array(0) { +} + +Warning: imap_fetch_overview() expects parameter 1 to be resource, array given in %s on line %d +NULL + +-- Testing with first argument value: %string|unicode%(6) "string" + +Warning: imap_fetch_overview() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d +NULL + +-- Testing with first argument value: %string|unicode%(6) "string" + +Warning: imap_fetch_overview() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d +NULL + +-- Testing with first argument value: %string|unicode%(11) "hello world" + +Warning: imap_fetch_overview() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d +NULL + +-- Testing with first argument value: object(classA)#1 (0) { +} + +Warning: imap_fetch_overview() expects parameter 1 to be resource, object given in %s on line %d +NULL + +-- Testing with first argument value: NULL + +Warning: imap_fetch_overview() expects parameter 1 to be resource, null given in %s on line %d +NULL + +-- Testing with first argument value: NULL + +Warning: imap_fetch_overview() expects parameter 1 to be resource, null given in %s on line %d +NULL +===DONE=== diff --git a/ext/imap/tests/imap_fetch_overview_variation2.phpt b/ext/imap/tests/imap_fetch_overview_variation2.phpt new file mode 100644 index 0000000000..0b341587cc --- /dev/null +++ b/ext/imap/tests/imap_fetch_overview_variation2.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test imap_fetch_overview() function : usage variations - diff data types as $msg_no arg +--SKIPIF-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?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 + +//Set mandatory response fields +$mandatoryFields = array( + 'size', + 'uid', + 'msgno', + 'recent', + 'flagged', + 'answered', + 'deleted', + 'seen', + 'draft', + ); + + +//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 { + foreach ($mandatoryFields as $mf) + { + $z = $overview[0]->$mf; + echo "$mf is $z\n"; + } + } + $iterator++; +}; + +fclose($fp); + +// clear the error stack +imap_errors(); +?> +===DONE=== +--CLEAN-- +<?php +require_once(dirname(__FILE__).'/clean.inc'); +?> +--EXPECTF-- +*** Testing imap_fetch_overview() : usage variations *** +Create a temporary mailbox and add 1 msgs +.. mailbox '{localhost/norsh}INBOX.phpttest' 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 + +-- 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 + +-- 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 + +-- 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) { +} + +Warning: imap_fetch_overview() expects parameter 2 to be %binary_string_optional%, array given in %s on line %d +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(7) of type (stream) + +Warning: imap_fetch_overview() expects parameter 2 to be %binary_string_optional%, resource given in %s on line %d +Syntax error in sequence +===DONE=== diff --git a/ext/imap/tests/imap_fetch_overview_variation3.phpt b/ext/imap/tests/imap_fetch_overview_variation3.phpt new file mode 100644 index 0000000000..5fa56b5f76 --- /dev/null +++ b/ext/imap/tests/imap_fetch_overview_variation3.phpt @@ -0,0 +1,80 @@ +--TEST-- +Test imap_fetch_overview() function : usage variations - FT_UID option +--SKIPIF-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?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=== +--CLEAN-- +<?php +require_once(dirname(__FILE__).'/clean.inc'); +?> +--EXPECTF-- +*** Testing imap_fetch_overview() : usage variations *** +Create a temporary mailbox and add 1 msgs +.. mailbox '{localhost/norsh}INBOX.phpttest' 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) + +Warning: imap_fetch_overview(): invalid value for the options parameter in %s on line %d + +Testing with option value:int(-%d) + +Warning: imap_fetch_overview(): invalid value for the options parameter in %s on line %d +===DONE=== diff --git a/ext/imap/tests/imap_fetch_overview_variation4.phpt b/ext/imap/tests/imap_fetch_overview_variation4.phpt new file mode 100644 index 0000000000..a5c2666310 --- /dev/null +++ b/ext/imap/tests/imap_fetch_overview_variation4.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test imap_fetch_overview() function : usage variations - different resources as $stream_id +--SKIPIF-- +<?php +extension_loaded('imap') or die('skip imap extension not available in this build'); +?> +--FILE-- +<?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=== +--EXPECTF-- +*** Testing imap_fetch_overview() : usage variations *** + +-- File Resource opened with fopen() -- +resource(%d) of type (stream) + +Warning: imap_fetch_overview(): supplied resource is not a valid imap resource in %s on line %d +bool(false) + +-- Directory Resource opened with opendir() -- +resource(%d) of type (stream) + +Warning: imap_fetch_overview(): supplied resource is not a valid imap resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/imap/tests/imap_fetch_overview_variation5.phpt b/ext/imap/tests/imap_fetch_overview_variation5.phpt new file mode 100644 index 0000000000..79861be7a2 --- /dev/null +++ b/ext/imap/tests/imap_fetch_overview_variation5.phpt @@ -0,0 +1,149 @@ +--TEST-- +Test imap_fetch_overview() function : usage variations - $msg_no argument +--SKIPIF-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?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 + +//Set mandatory response fields +$mandatoryFields = array( + 'size', + 'uid', + 'msgno', + 'recent', + 'flagged', + 'answered', + 'deleted', + 'seen', + 'draft', + ); + +$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"; + foreach ($mandatoryFields as $mf) + { + $z = $ov->$mf; + echo "$mf is $z\n"; + } + } + } +} + +// clear error stack +imap_errors(); +?> +===DONE=== +--CLEAN-- +<?php +require_once(dirname(__FILE__).'/clean.inc'); +?> +--EXPECTF-- +*** Testing imap_fetch_overview() : usage variations *** +Create a temporary mailbox and add 3 msgs +.. mailbox '{localhost/norsh}INBOX.phpttest' 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 + +-- $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 + +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 + +-- $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 + +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 + +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 +===DONE=== diff --git a/ext/imap/tests/imap_fetch_overview_variation6.phpt b/ext/imap/tests/imap_fetch_overview_variation6.phpt new file mode 100644 index 0000000000..fda937e243 --- /dev/null +++ b/ext/imap/tests/imap_fetch_overview_variation6.phpt @@ -0,0 +1,125 @@ +--TEST-- +Test imap_fetch_overview() function : usage variations - multipart message +--SKIPIF-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?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); + +//Set mandatory response fields +$mandatoryFields = array( + 'size', + 'uid', + 'msgno', + 'recent', + 'flagged', + 'answered', + 'deleted', + 'seen', + 'draft', + ); + +// refresh msg numbers +imap_check($stream_id); +$msg_no = 1; + +$a = imap_fetch_overview($stream_id, $msg_no); +echo "\n--> Object #1\n"; +foreach ($mandatoryFields as $mf) +{ + $z = $a[0]->$mf; + echo "$mf is $z\n"; +} + + + + +/** + * 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=== +--CLEAN-- +<?php +require_once(dirname(__FILE__).'/clean.inc'); +?> +--EXPECTF-- +*** Testing imap_fetch_overview() : usage variations *** +Create a temporary mailbox and add 0 msgs +.. mailbox '{localhost/norsh}INBOX.phpttest' 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 +===DONE=== |