From f6e659c6dd65b61124913a29f9d88d89a23522cb Mon Sep 17 00:00:00 2001 From: Zoe Slattery Date: Wed, 17 Dec 2008 15:05:38 +0000 Subject: [PATCH] Miscellaneous tests for ext/imap --- ext/imap/tests/imap_8bit_basic.phpt | 33 +++ ext/imap/tests/imap_alerts_error.phpt | 31 +++ ext/imap/tests/imap_append_basic.phpt | 72 ++++++ ext/imap/tests/imap_base64_basic.phpt | 47 ++++ ext/imap/tests/imap_binary_basic.phpt | 48 ++++ ext/imap/tests/imap_body_basic.phpt | 44 ++++ ext/imap/tests/imap_bodystruct_basic.phpt | 93 +++++++ ext/imap/tests/imap_clearflag_full_basic.phpt | 127 ++++++++++ ext/imap/tests/imap_close_basic.phpt | 56 +++++ ext/imap/tests/imap_close_error.phpt | 45 ++++ ext/imap/tests/imap_close_variation1.phpt | 214 +++++++++++++++++ ext/imap/tests/imap_close_variation2.phpt | 227 ++++++++++++++++++ ext/imap/tests/imap_close_variation3.phpt | 47 ++++ ext/imap/tests/imap_close_variation4.phpt | 93 +++++++ ext/imap/tests/imap_createmailbox_basic.phpt | 69 ++++++ ext/imap/tests/imap_errors_basic.phpt | 55 +++++ ext/imap/tests/imap_fetchbody_basic.phpt | 83 +++++++ ext/imap/tests/imap_fetchbody_error.phpt | 57 +++++ ext/imap/tests/imap_fetchbody_variation1.phpt | 219 +++++++++++++++++ ext/imap/tests/imap_fetchbody_variation2.phpt | 223 +++++++++++++++++ ext/imap/tests/imap_fetchbody_variation3.phpt | 219 +++++++++++++++++ ext/imap/tests/imap_fetchbody_variation4.phpt | 79 ++++++ ext/imap/tests/imap_fetchbody_variation5.phpt | 46 ++++ ext/imap/tests/imap_fetchbody_variation6.phpt | 72 ++++++ 24 files changed, 2299 insertions(+) create mode 100644 ext/imap/tests/imap_8bit_basic.phpt create mode 100644 ext/imap/tests/imap_alerts_error.phpt create mode 100644 ext/imap/tests/imap_append_basic.phpt create mode 100644 ext/imap/tests/imap_base64_basic.phpt create mode 100644 ext/imap/tests/imap_binary_basic.phpt create mode 100644 ext/imap/tests/imap_body_basic.phpt create mode 100644 ext/imap/tests/imap_bodystruct_basic.phpt create mode 100644 ext/imap/tests/imap_clearflag_full_basic.phpt create mode 100644 ext/imap/tests/imap_close_basic.phpt create mode 100644 ext/imap/tests/imap_close_error.phpt create mode 100644 ext/imap/tests/imap_close_variation1.phpt create mode 100644 ext/imap/tests/imap_close_variation2.phpt create mode 100644 ext/imap/tests/imap_close_variation3.phpt create mode 100644 ext/imap/tests/imap_close_variation4.phpt create mode 100644 ext/imap/tests/imap_createmailbox_basic.phpt create mode 100644 ext/imap/tests/imap_errors_basic.phpt create mode 100644 ext/imap/tests/imap_fetchbody_basic.phpt create mode 100644 ext/imap/tests/imap_fetchbody_error.phpt create mode 100644 ext/imap/tests/imap_fetchbody_variation1.phpt create mode 100644 ext/imap/tests/imap_fetchbody_variation2.phpt create mode 100644 ext/imap/tests/imap_fetchbody_variation3.phpt create mode 100644 ext/imap/tests/imap_fetchbody_variation4.phpt create mode 100644 ext/imap/tests/imap_fetchbody_variation5.phpt create mode 100644 ext/imap/tests/imap_fetchbody_variation6.phpt diff --git a/ext/imap/tests/imap_8bit_basic.phpt b/ext/imap/tests/imap_8bit_basic.phpt new file mode 100644 index 0000000000..aaa0591722 --- /dev/null +++ b/ext/imap/tests/imap_8bit_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test imap_8bit() function : basic functionality +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECT-- +*** 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=== diff --git a/ext/imap/tests/imap_alerts_error.phpt b/ext/imap/tests/imap_alerts_error.phpt new file mode 100644 index 0000000000..ab13ec4632 --- /dev/null +++ b/ext/imap/tests/imap_alerts_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test imap_alerts() function : error conditions +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing imap_alerts() : error conditions *** + +-- Testing imap_alerts() function with one argument -- + +Warning: imap_alerts() expects exactly 0 parameters, 1 given in %s on line %d +NULL +===DONE=== diff --git a/ext/imap/tests/imap_append_basic.phpt b/ext/imap/tests/imap_append_basic.phpt new file mode 100644 index 0000000000..60847ce716 --- /dev/null +++ b/ext/imap/tests/imap_append_basic.phpt @@ -0,0 +1,72 @@ +--TEST-- +Test imap_append() function : basic functionality +--SKIPIF-- + +--FILE-- +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=== +--CLEAN-- + +--EXPECTF-- +*** 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=== + diff --git a/ext/imap/tests/imap_base64_basic.phpt b/ext/imap/tests/imap_base64_basic.phpt new file mode 100644 index 0000000000..a64be276d9 --- /dev/null +++ b/ext/imap/tests/imap_base64_basic.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test imap_base64() function : basic functionality +--SKIPIF-- + +--FILE-- +.<,'; +$base64 = base64_encode($str); +if (imap_base64($base64) == $str) { + echo "TEST PASSED\n"; +} else { + echo "TEST FAILED"; +} + +$hex = b'x00\x01\x02\x03\x04\x05\x06\xFA\xFB\xFC\xFD\xFE\xFF'; +$base64 = base64_encode($hex); +if (imap_base64($base64) == $hex) { + echo "TEST PASSED\n"; +} else { + echo "TEST FAILED"; +} + +?> +===Done=== +--EXPECT-- +*** Testing imap_base64() : basic functionality *** +TEST PASSED +TEST PASSED +TEST PASSED +===Done=== diff --git a/ext/imap/tests/imap_binary_basic.phpt b/ext/imap/tests/imap_binary_basic.phpt new file mode 100644 index 0000000000..bd4eabba51 --- /dev/null +++ b/ext/imap/tests/imap_binary_basic.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test imap_binary() function : basic functionality +--SKIPIF-- + +--FILE-- +.<,'; +$base64 = imap_binary($str); +var_dump(bin2hex($base64)); + +echo "Encode some hexadecimal data\n"; +$hex = b'x00\x01\x02\x03\x04\x05\x06\xFA\xFB\xFC\xFD\xFE\xFF'; +$base64 = imap_binary($hex); +var_dump(bin2hex($base64)); + +?> +===Done=== +--EXPECTF-- +*** Testing imap_binary() : basic functionality *** +Encode as short string +%string|unicode%(136) "5647687063794270637942686269426c654746746347786c49484e30636d6c755a794230627942695a53426959584e6c49445930494756755932396b0d0a5a57513d0d0a" +Encode a string which results in more than 60 charters of output +%string|unicode%(200) "56476870637942706379426849477876626d6367633352796157356e4948647064476767636d567a64577830637942706269427462334a6c4948526f0d0a595734674e6a416759326868636d466a64475679637942765a694276645852776458513d0d0a" +Encode a string with special characters +%string|unicode%(60) "5879737450587464573130374f30422b497a3876506934384c413d3d0d0a" +Encode some hexadecimal data +%string|unicode%(144) "65444177584867774d5678344d444a636544417a584867774e4678344d445663654441325848684751567834526b4a6365455a4458486847524678340d0a526b566365455a470d0a" +===Done=== diff --git a/ext/imap/tests/imap_body_basic.phpt b/ext/imap/tests/imap_body_basic.phpt new file mode 100644 index 0000000000..7cd5181116 --- /dev/null +++ b/ext/imap/tests/imap_body_basic.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test imap_body() function : basic functionality +--SKIPIF-- + +--FILE-- +Nmsgs . "\n"; + +// show body for msg 1 +var_dump(imap_body($imap_stream, 1)); + +imap_close($imap_stream); +?> +===Done=== +--CLEAN-- + +--EXPECTF-- +*** 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 +string(%d) "1: this is a test message, please ignore%a" +===Done=== \ No newline at end of file diff --git a/ext/imap/tests/imap_bodystruct_basic.phpt b/ext/imap/tests/imap_bodystruct_basic.phpt new file mode 100644 index 0000000000..4edc753b60 --- /dev/null +++ b/ext/imap/tests/imap_bodystruct_basic.phpt @@ -0,0 +1,93 @@ +--TEST-- +Test imap_bodystruct() function : basic functionality +--SKIPIF-- + +--FILE-- +$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=== +--CLEAN-- + +--EXPECTF-- +*** 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 '{localhost/norsh}INBOX.phpttest' 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=== diff --git a/ext/imap/tests/imap_clearflag_full_basic.phpt b/ext/imap/tests/imap_clearflag_full_basic.phpt new file mode 100644 index 0000000000..fb7465dc4e --- /dev/null +++ b/ext/imap/tests/imap_clearflag_full_basic.phpt @@ -0,0 +1,127 @@ +--TEST-- +Test imap_clearflag_full() function : basic functionality +--SKIPIF-- + +--FILE-- +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=== +--CLEAN-- + +--EXPECTF-- +*** Testing imap_clearflag_full() : basic functionality *** +Create a new mailbox for test +Create a temporary mailbox and add 10 msgs +.. mailbox '{localhost/norsh}INBOX.%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=== diff --git a/ext/imap/tests/imap_close_basic.phpt b/ext/imap/tests/imap_close_basic.phpt new file mode 100644 index 0000000000..a99853071b --- /dev/null +++ b/ext/imap/tests/imap_close_basic.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test imap_close() function : basic functionality +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** 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=== diff --git a/ext/imap/tests/imap_close_error.phpt b/ext/imap/tests/imap_close_error.phpt new file mode 100644 index 0000000000..fd32f3edd8 --- /dev/null +++ b/ext/imap/tests/imap_close_error.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test imap_close() function : error conditions - incorrect number of args +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing imap_close() : error conditions *** + +-- Testing imap_close() function with Zero arguments -- + +Warning: imap_close() expects at least 1 parameter, 0 given in %s on line %d +NULL + +-- Testing imap_close() function with more than expected no. of arguments -- + +Warning: imap_close() expects at most 2 parameters, 3 given in %s on line %d +NULL +===DONE=== diff --git a/ext/imap/tests/imap_close_variation1.phpt b/ext/imap/tests/imap_close_variation1.phpt new file mode 100644 index 0000000000..320390527e --- /dev/null +++ b/ext/imap/tests/imap_close_variation1.phpt @@ -0,0 +1,214 @@ +--TEST-- +Test imap_close() function : usage variations - different data types as $stream_id arg +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing imap_close() : usage variations *** + +-- Iteration 1 -- + +Warning: imap_close() expects parameter 1 to be resource, integer given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 2 -- + +Warning: imap_close() expects parameter 1 to be resource, integer given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 3 -- + +Warning: imap_close() expects parameter 1 to be resource, integer given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 4 -- + +Warning: imap_close() expects parameter 1 to be resource, integer given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 5 -- + +Warning: imap_close() expects parameter 1 to be resource, double given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 6 -- + +Warning: imap_close() expects parameter 1 to be resource, double given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 7 -- + +Warning: imap_close() expects parameter 1 to be resource, double given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 8 -- + +Warning: imap_close() expects parameter 1 to be resource, double given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 9 -- + +Warning: imap_close() expects parameter 1 to be resource, double given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 10 -- + +Warning: imap_close() expects parameter 1 to be resource, null given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 11 -- + +Warning: imap_close() expects parameter 1 to be resource, null given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 12 -- + +Warning: imap_close() expects parameter 1 to be resource, boolean given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 13 -- + +Warning: imap_close() expects parameter 1 to be resource, boolean given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 14 -- + +Warning: imap_close() expects parameter 1 to be resource, boolean given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 15 -- + +Warning: imap_close() expects parameter 1 to be resource, boolean given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 16 -- + +Warning: imap_close() expects parameter 1 to be resource, %unicode_string_optional% given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 17 -- + +Warning: imap_close() expects parameter 1 to be resource, %unicode_string_optional% given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 18 -- + +Warning: imap_close() expects parameter 1 to be resource, array given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 19 -- + +Warning: imap_close() expects parameter 1 to be resource, %unicode_string_optional% given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 20 -- + +Warning: imap_close() expects parameter 1 to be resource, %unicode_string_optional% given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 21 -- + +Warning: imap_close() expects parameter 1 to be resource, %unicode_string_optional% given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 22 -- + +Warning: imap_close() expects parameter 1 to be resource, object given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 23 -- + +Warning: imap_close() expects parameter 1 to be resource, null given in %simap_close_variation1.php on line 80 +NULL + +-- Iteration 24 -- + +Warning: imap_close() expects parameter 1 to be resource, null given in %simap_close_variation1.php on line 80 +NULL +===DONE=== diff --git a/ext/imap/tests/imap_close_variation2.phpt b/ext/imap/tests/imap_close_variation2.phpt new file mode 100644 index 0000000000..6378e88adf --- /dev/null +++ b/ext/imap/tests/imap_close_variation2.phpt @@ -0,0 +1,227 @@ +--TEST-- +Test imap_close() function : usage variations - different data types as $options arg +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** Testing imap_close() : usage variations *** +Create a temporary mailbox and add 3 msgs +.. mailbox '{localhost/norsh}INBOX.phpttest' created + +-- Iteration 1 -- +bool(true) +CL_EXPUNGE was not set, 3 msgs in mailbox + +-- Iteration 2 -- + +Warning: imap_close(): invalid value for the flags parameter in %s on line %d +bool(false) + +-- Iteration 3 -- +bool(true) +CL_EXPUNGE was set + +-- Iteration 4 -- + +Warning: imap_close(): invalid value for the flags parameter in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: imap_close(): invalid value for the flags parameter in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: imap_close(): invalid value for the flags parameter in %s on line %d +bool(false) + +-- Iteration 7 -- + +Warning: imap_close(): invalid value for the flags parameter in %s on line %d +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 -- + +Warning: imap_close(): invalid value for the flags parameter in %s on line %d +bool(false) + +-- Iteration 13 -- +bool(true) +CL_EXPUNGE was not set, 3 msgs in mailbox + +-- Iteration 14 -- + +Warning: imap_close(): invalid value for the flags parameter in %s on line %d +bool(false) + +-- Iteration 15 -- +bool(true) +CL_EXPUNGE was not set, 3 msgs in mailbox + +-- Iteration 16 -- + +Warning: imap_close() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d +NULL +CL_EXPUNGE was not set, 3 msgs in mailbox + +-- Iteration 17 -- + +Warning: imap_close() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d +NULL +CL_EXPUNGE was not set, 3 msgs in mailbox + +-- Iteration 18 -- + +Warning: imap_close() expects parameter 2 to be long, array given in %s on line %d +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=== diff --git a/ext/imap/tests/imap_close_variation3.phpt b/ext/imap/tests/imap_close_variation3.phpt new file mode 100644 index 0000000000..6f6161aa23 --- /dev/null +++ b/ext/imap/tests/imap_close_variation3.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test imap_close() function : usage variations - different streams +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing imap_close() : usage variations *** + +-- File Resource opened with fopen() -- +resource(%d) of type (stream) + +Warning: imap_close(): supplied resource is not a valid imap resource in %s on line %d +bool(false) +resource(%d) of type (stream) + +-- Directory Resource opened with opendir() -- +resource(%d) of type (stream) + +Warning: imap_close(): supplied resource is not a valid imap resource in %s on line %d +bool(false) +resource(%d) of type (stream) +===DONE=== diff --git a/ext/imap/tests/imap_close_variation4.phpt b/ext/imap/tests/imap_close_variation4.phpt new file mode 100644 index 0000000000..65b05786f1 --- /dev/null +++ b/ext/imap/tests/imap_close_variation4.phpt @@ -0,0 +1,93 @@ +--TEST-- +Test imap_close() function : usage variations - different ints as $options arg +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** Testing imap_close() : usage variations *** +Create a temporary mailbox and add 3 msgs +.. mailbox '{localhost/norsh}INBOX.phpttest' created + +-- Iteration 1 -- +bool(true) +CL_EXPUNGE was not set, 3 msgs in mailbox + +-- Iteration 2 -- +bool(true) +CL_EXPUNGE was set + +-- Iteration 3 -- + +Warning: imap_close(): invalid value for the flags parameter in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: imap_close(): invalid value for the flags parameter in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: imap_close(): invalid value for the flags parameter in %s on line %d +bool(false) +===DONE=== diff --git a/ext/imap/tests/imap_createmailbox_basic.phpt b/ext/imap/tests/imap_createmailbox_basic.phpt new file mode 100644 index 0000000000..431d59f97d --- /dev/null +++ b/ext/imap/tests/imap_createmailbox_basic.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test imap_createmailbox() function : basic functionality +--SKIPIF-- + +--FILE-- +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=== +--EXPECTF-- +*** 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=== diff --git a/ext/imap/tests/imap_errors_basic.phpt b/ext/imap/tests/imap_errors_basic.phpt new file mode 100644 index 0000000000..9d2ca30ece --- /dev/null +++ b/ext/imap/tests/imap_errors_basic.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test imap_errors() function : basic functionality +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECTF-- +*** Testing imap_errors() : basic functionality *** +Issue open with invalid password with normal default number of retries, i.e 3 + +Warning: imap_open(): Couldn't open stream %s in %s on line %d +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 + +Warning: imap_open(): Couldn't open stream %s in %s on line %d +List any errors +array(%d) { + [0]=> + string(%d) "%a +} +===Done=== diff --git a/ext/imap/tests/imap_fetchbody_basic.phpt b/ext/imap/tests/imap_fetchbody_basic.phpt new file mode 100644 index 0000000000..4aa080f46c --- /dev/null +++ b/ext/imap/tests/imap_fetchbody_basic.phpt @@ -0,0 +1,83 @@ +--TEST-- +Test imap_fetchbody() function : basic functionality +--XFAIL-- +Expected to fail - missing unicode implementation +--SKIPIF-- + +--FILE-- + 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=== +--CLEAN-- + +--EXPECTF-- +*** Testing imap_fetchbody() : basic functionality *** +Create a temporary mailbox and add 1 msgs +.. mailbox '{localhost/norsh}INBOX.phpttest' 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=== diff --git a/ext/imap/tests/imap_fetchbody_error.phpt b/ext/imap/tests/imap_fetchbody_error.phpt new file mode 100644 index 0000000000..77b71644fd --- /dev/null +++ b/ext/imap/tests/imap_fetchbody_error.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test imap_fetchbody() function : error conditions - incorrect number of args +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** 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 '{localhost/norsh}INBOX.phpttest' created + +Warning: imap_fetchbody() expects at most 4 parameters, 5 given in %s on line %d +NULL + +-- Testing imap_fetchbody() function with less than expected no. of arguments -- + +Warning: imap_fetchbody() expects at least 3 parameters, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/imap/tests/imap_fetchbody_variation1.phpt b/ext/imap/tests/imap_fetchbody_variation1.phpt new file mode 100644 index 0000000000..5f587df4a6 --- /dev/null +++ b/ext/imap/tests/imap_fetchbody_variation1.phpt @@ -0,0 +1,219 @@ +--TEST-- +Test imap_fetchbody() function : usage variation - diff data types as $stream_id arg +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing imap_fetchbody() : usage variations *** + +-- Iteration 1 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, integer given in %s on line 85 +NULL + +-- Iteration 2 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, integer given in %s on line 85 +NULL + +-- Iteration 3 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, integer given in %s on line 85 +NULL + +-- Iteration 4 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, integer given in %s on line 85 +NULL + +-- Iteration 5 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, double given in %s on line 85 +NULL + +-- Iteration 6 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, double given in %s on line 85 +NULL + +-- Iteration 7 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, double given in %s on line 85 +NULL + +-- Iteration 8 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, double given in %s on line 85 +NULL + +-- Iteration 9 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, double given in %s on line 85 +NULL + +-- Iteration 10 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, null given in %s on line 85 +NULL + +-- Iteration 11 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, null given in %s on line 85 +NULL + +-- Iteration 12 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, boolean given in %s on line 85 +NULL + +-- Iteration 13 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, boolean given in %s on line 85 +NULL + +-- Iteration 14 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, boolean given in %s on line 85 +NULL + +-- Iteration 15 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, boolean given in %s on line 85 +NULL + +-- Iteration 16 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line 85 +NULL + +-- Iteration 17 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line 85 +NULL + +-- Iteration 18 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, array given in %s on line 85 +NULL + +-- Iteration 19 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line 85 +NULL + +-- Iteration 20 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line 85 +NULL + +-- Iteration 21 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line 85 +NULL + +-- Iteration 22 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, object given in %s on line 85 +NULL + +-- Iteration 23 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, null given in %s on line 85 +NULL + +-- Iteration 24 -- + +Warning: imap_fetchbody() expects parameter 1 to be resource, null given in %s on line 85 +NULL +===DONE=== diff --git a/ext/imap/tests/imap_fetchbody_variation2.phpt b/ext/imap/tests/imap_fetchbody_variation2.phpt new file mode 100644 index 0000000000..850770d16b --- /dev/null +++ b/ext/imap/tests/imap_fetchbody_variation2.phpt @@ -0,0 +1,223 @@ +--TEST-- +Test imap_fetchbody() function : usage variation - diff data types as $msg_no arg +--XFAIL-- +Missing unicode implementation in ext/imap +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** Testing imap_fetchbody() : usage variations *** +Create a temporary mailbox and add 1 msgs +.. mailbox '{localhost/norsh}INBOX.phpttest' created + +-- Iteration 1 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 2 -- +string(%d) "1: this is a test message, please ignore%a" + +-- Iteration 3 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 7 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 8 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 9 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 10 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 11 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 12 -- +string(%d) "1: this is a test message, please ignore%a" + +-- Iteration 13 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 14 -- +string(%d) "1: this is a test message, please ignore%a" + +-- Iteration 15 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 16 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 22 -- + +Notice: Object of class classA could not be converted to int in %s on line %d +string(42) "1: this is a test message, please ignore%a" + +-- Iteration 23 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + +-- Iteration 24 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) +===DONE=== diff --git a/ext/imap/tests/imap_fetchbody_variation3.phpt b/ext/imap/tests/imap_fetchbody_variation3.phpt new file mode 100644 index 0000000000..b3d7a8933c --- /dev/null +++ b/ext/imap/tests/imap_fetchbody_variation3.phpt @@ -0,0 +1,219 @@ +--TEST-- +Test imap_fetchbody() function : usage variation - diff data types as $section arg +--XFAIL-- +Missing unicode implementaion in ex/imap +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** 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 -- + +Warning: imap_fetchbody() expects parameter 3 to be %unicode_string_optional%, array given in %s on line 87 +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=== diff --git a/ext/imap/tests/imap_fetchbody_variation4.phpt b/ext/imap/tests/imap_fetchbody_variation4.phpt new file mode 100644 index 0000000000..6b9579abd4 --- /dev/null +++ b/ext/imap/tests/imap_fetchbody_variation4.phpt @@ -0,0 +1,79 @@ +--TEST-- +Test imap_fetchbody() function : usage variations - FT_UID option +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** Testing imap_fetchbody() : 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_fetchbody(): invalid value for the options parameter in %s on line %d +FT_UID not valid + +-- Iteration 6 -- + +Warning: imap_fetchbody(): invalid value for the options parameter in %s on line %d +FT_UID not valid +===DONE=== diff --git a/ext/imap/tests/imap_fetchbody_variation5.phpt b/ext/imap/tests/imap_fetchbody_variation5.phpt new file mode 100644 index 0000000000..dfc5e9fa55 --- /dev/null +++ b/ext/imap/tests/imap_fetchbody_variation5.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test imap_fetchbody() function : usage variation - different resources as $stream_id arg +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing imap_fetchbody() : usage variations *** + +-- File Resource opened with fopen() -- +resource(5) of type (stream) + +Warning: imap_fetchbody() expects at least 3 parameters, 2 given in %s on line %d +NULL + +-- Directory Resource opened with opendir() -- +resource(6) of type (stream) + +Warning: imap_fetchbody() expects at least 3 parameters, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/imap/tests/imap_fetchbody_variation6.phpt b/ext/imap/tests/imap_fetchbody_variation6.phpt new file mode 100644 index 0000000000..35bceb3cad --- /dev/null +++ b/ext/imap/tests/imap_fetchbody_variation6.phpt @@ -0,0 +1,72 @@ +--TEST-- +Test imap_fetchbody() function : usage variations - $msg_no arg +--XFAIL-- +Missing unicoe implementation in /ext/imap +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** Testing imap_fetchbody() : usage variations *** +Create a temporary mailbox and add 3 msgs +.. mailbox '{localhost/norsh}INBOX.phpttest' created + +-- $msg_no is 0 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + + +-- $msg_no is 4 -- + +Warning: imap_fetchbody(): Bad message number in %s on line %d +bool(false) + + +-- $msg_no is 1,3 -- + +Notice: A non well formed numeric value encountered in %s on line %d +%unicode|string%(%d) "1: this is a test message, please ignore%a" + +-- $msg_no is 1:3 -- + +Notice: A non well formed numeric value encountered in %s on line %d +%unicode|string%(%d) "1: this is a test message, please ignore%a" +===DONE=== -- 2.40.0