From: Zoe Slattery Date: Fri, 23 Jan 2009 15:32:48 +0000 (+0000) Subject: IMPA fetchheader tests X-Git-Tag: php-5.2.9RC1~51 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0ef277d3ae39559f1f96bde39d57043c0792953;p=php IMPA fetchheader tests --- diff --git a/ext/imap/tests/imap_fetchheader_basic.phpt b/ext/imap/tests/imap_fetchheader_basic.phpt new file mode 100644 index 0000000000..2e47b0ce5f --- /dev/null +++ b/ext/imap/tests/imap_fetchheader_basic.phpt @@ -0,0 +1,83 @@ +--TEST-- +Test imap_fetchheader() function : basic functions +--SKIPIF-- + +--FILE-- + 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=== +--CLEAN-- + +--EXPECTF-- +*** 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=== diff --git a/ext/imap/tests/imap_fetchheader_error.phpt b/ext/imap/tests/imap_fetchheader_error.phpt new file mode 100644 index 0000000000..143e45ebcd --- /dev/null +++ b/ext/imap/tests/imap_fetchheader_error.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test imap_fetchheader() function : error conditions - incorrect number of args +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing imap_fetchheader() : error conditions *** + +-- Testing imap_fetchheader() function with more than expected no. of arguments -- + +Warning: Wrong parameter count for imap_fetchheader() in %s on line %d +NULL + +-- Testing imap_fetchheader() function with less than expected no. of arguments -- + +Warning: Wrong parameter count for imap_fetchheader() in %s on line %d +NULL +===DONE=== diff --git a/ext/imap/tests/imap_fetchheader_variation1.phpt b/ext/imap/tests/imap_fetchheader_variation1.phpt new file mode 100644 index 0000000000..b4f6d17a56 --- /dev/null +++ b/ext/imap/tests/imap_fetchheader_variation1.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test imap_fetchheader() function : usage variations - diff data types as $stream_id arg +--SKIPIF-- + +--FILE-- + 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=== +--EXPECTF-- +*** Testing imap_fetchheader() : usage variations *** + +-- Iteration 1 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 2 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 3 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 7 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 8 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 9 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 10 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 11 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 12 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 13 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 14 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 15 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 16 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 22 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 23 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 24 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 25 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 26 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) + +-- Iteration 27 -- + +Warning: imap_fetchheader(): supplied argument is not a valid imap resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/imap/tests/imap_fetchheader_variation2.phpt b/ext/imap/tests/imap_fetchheader_variation2.phpt new file mode 100644 index 0000000000..65d5d85578 --- /dev/null +++ b/ext/imap/tests/imap_fetchheader_variation2.phpt @@ -0,0 +1,292 @@ +--TEST-- +Test imap_fetchheader() function : usage variations - diff data types for $msg_no arg +--SKIPIF-- + +--FILE-- + 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=== +--CLEAN-- + +===DONE=== +--EXPECTF-- +*** Testing imap_fetchheader() : usage variations *** +Create a temporary mailbox and add 1 msgs +.. mailbox '{localhost/norsh}INBOX.phpttest' created + +-- Iteration 1 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 2 -- +string(%d) "From: foo@anywhere.com +Subject: Test msg 1 +To: %s +MIME-Version: 1.0 +Content-Type: MULTIPART/mixed; BOUNDARY="%s" + +" + +-- Iteration 3 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 7 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 8 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 9 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 10 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 11 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 12 -- +string(%d) "From: foo@anywhere.com +Subject: Test msg 1 +To: %s +MIME-Version: 1.0 +Content-Type: MULTIPART/mixed; BOUNDARY="%s" + +" + +-- Iteration 13 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 14 -- +string(%d) "From: foo@anywhere.com +Subject: Test msg 1 +To: %s +MIME-Version: 1.0 +Content-Type: MULTIPART/mixed; BOUNDARY="%s" + +" + +-- Iteration 15 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 16 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 22 -- +string(%d) "From: foo@anywhere.com +Subject: Test msg 1 +To: %s +MIME-Version: 1.0 +Content-Type: MULTIPART/mixed; BOUNDARY="%s" + +" + +-- Iteration 23 -- +string(%d) "From: foo@anywhere.com +Subject: Test msg 1 +To: %s +MIME-Version: 1.0 +Content-Type: MULTIPART/mixed; BOUNDARY="%s" + +" + +-- Iteration 24 -- +string(%d) "From: foo@anywhere.com +Subject: Test msg 1 +To: %s +MIME-Version: 1.0 +Content-Type: MULTIPART/mixed; BOUNDARY="%s" + +" + +-- Iteration 25 -- + +Notice: Object of class classA could not be converted to int in %s on line %d +string(%d) "From: foo@anywhere.com +Subject: Test msg 1 +To: %s +MIME-Version: 1.0 +Content-Type: MULTIPART/mixed; BOUNDARY="%s" + +" + +-- Iteration 26 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 27 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + +-- Iteration 28 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) +===DONE=== diff --git a/ext/imap/tests/imap_fetchheader_variation3.phpt b/ext/imap/tests/imap_fetchheader_variation3.phpt new file mode 100644 index 0000000000..e21c1a966c --- /dev/null +++ b/ext/imap/tests/imap_fetchheader_variation3.phpt @@ -0,0 +1,77 @@ +--TEST-- +Test imap_fetchheader() function : usage variations - FT_UID option +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** Testing imap_fetchheader() : usage variations *** +Create a temporary mailbox and add 1 msgs +.. mailbox '{localhost/norsh}INBOX.phpttest' created + +-- Iteration 1 -- +FT_UID valid + +-- Iteration 2 -- +FT_UID valid + +-- Iteration 3 -- +FT_UID valid + +-- Iteration 4 -- +FT_UID valid + +-- Iteration 5 -- + +Warning: imap_fetchheader(): invalid value for the options parameter in %s on line %d +FT_UID not valid + +-- Iteration 6 -- + +Warning: imap_fetchheader(): invalid value for the options parameter in %s on line %d +FT_UID not valid +===DONE=== diff --git a/ext/imap/tests/imap_fetchheader_variation4.phpt b/ext/imap/tests/imap_fetchheader_variation4.phpt new file mode 100644 index 0000000000..b4b19e3d37 --- /dev/null +++ b/ext/imap/tests/imap_fetchheader_variation4.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test imap_fetchheader() function : usage variations - diff resource types as $stream_id +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing imap_fetchheader() : usage variations *** + +-- File Resource opened with fopen() -- +resource(%d) of type (stream) + +Warning: imap_fetchheader(): 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_fetchheader(): supplied resource is not a valid imap resource in %s on line %d +bool(false) +===DONE=== \ No newline at end of file diff --git a/ext/imap/tests/imap_fetchheader_variation5.phpt b/ext/imap/tests/imap_fetchheader_variation5.phpt new file mode 100644 index 0000000000..f0f5fd597e --- /dev/null +++ b/ext/imap/tests/imap_fetchheader_variation5.phpt @@ -0,0 +1,79 @@ +--TEST-- +Test imap_fetchheader() function : usage variations - $msg_no argument +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** Testing imap_fetchheader() : usage variations *** +Create a temporary mailbox and add 3 msgs +.. mailbox '{localhost/norsh}INBOX.phpttest' created + +-- $msg_no is 0 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + + +-- $msg_no is 4 -- + +Warning: imap_fetchheader(): Bad message number in %s on line %d +bool(false) + + +-- $msg_no is 1,3 -- +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 -- +string(%d) "From: foo@anywhere.com +Subject: Test msg 1 +To: %s +MIME-Version: 1.0 +Content-Type: MULTIPART/mixed; BOUNDARY="%s" + +" +===DONE===