From 0fe72d902655003870dae32296ceab60e686de7f Mon Sep 17 00:00:00 2001 From: Dave Kelsey Date: Fri, 23 Jan 2009 17:12:15 +0000 Subject: [PATCH] added some mail tests. Tested on windows, linux and linux 64bit --- ext/standard/tests/mail/ezmlm_hash_basic.phpt | 25 +++ .../tests/mail/ezmlm_hash_basic_64bit.phpt | 25 +++ ext/standard/tests/mail/ezmlm_hash_error.phpt | 66 ++++++ .../tests/mail/ezmlm_hash_variation1.phpt | 193 ++++++++++++++++++ ext/standard/tests/mail/mail_basic.phpt | 59 ++++++ ext/standard/tests/mail/mail_basic2.phpt | 43 ++++ ext/standard/tests/mail/mail_basic3.phpt | 35 ++++ ext/standard/tests/mail/mail_basic4.phpt | 36 ++++ ext/standard/tests/mail/mail_basic5.phpt | 34 +++ .../tests/mail/mail_basic_alt1-win32.phpt | 95 +++++++++ .../tests/mail/mail_basic_alt2-win32.phpt | 93 +++++++++ .../tests/mail/mail_basic_alt3-win32.phpt | 93 +++++++++ .../tests/mail/mail_basic_alt4-win32.phpt | 94 +++++++++ ext/standard/tests/mail/mail_error.phpt | 44 ++++ ext/standard/tests/mail/mail_include.inc | 150 ++++++++++++++ ext/standard/tests/mail/mail_skipif.inc | 16 ++ ext/standard/tests/mail/mail_variation1.phpt | 30 +++ ext/standard/tests/mail/mail_variation2.phpt | 39 ++++ .../tests/mail/mail_variation_alt1-win32.phpt | 92 +++++++++ .../tests/mail/mail_variation_alt2-win32.phpt | 92 +++++++++ .../tests/mail/mail_variation_alt3-win32.phpt | 91 +++++++++ 21 files changed, 1445 insertions(+) create mode 100644 ext/standard/tests/mail/ezmlm_hash_basic.phpt create mode 100644 ext/standard/tests/mail/ezmlm_hash_basic_64bit.phpt create mode 100644 ext/standard/tests/mail/ezmlm_hash_error.phpt create mode 100644 ext/standard/tests/mail/ezmlm_hash_variation1.phpt create mode 100644 ext/standard/tests/mail/mail_basic.phpt create mode 100644 ext/standard/tests/mail/mail_basic2.phpt create mode 100644 ext/standard/tests/mail/mail_basic3.phpt create mode 100644 ext/standard/tests/mail/mail_basic4.phpt create mode 100644 ext/standard/tests/mail/mail_basic5.phpt create mode 100644 ext/standard/tests/mail/mail_basic_alt1-win32.phpt create mode 100644 ext/standard/tests/mail/mail_basic_alt2-win32.phpt create mode 100644 ext/standard/tests/mail/mail_basic_alt3-win32.phpt create mode 100644 ext/standard/tests/mail/mail_basic_alt4-win32.phpt create mode 100644 ext/standard/tests/mail/mail_error.phpt create mode 100644 ext/standard/tests/mail/mail_include.inc create mode 100644 ext/standard/tests/mail/mail_skipif.inc create mode 100644 ext/standard/tests/mail/mail_variation1.phpt create mode 100644 ext/standard/tests/mail/mail_variation2.phpt create mode 100644 ext/standard/tests/mail/mail_variation_alt1-win32.phpt create mode 100644 ext/standard/tests/mail/mail_variation_alt2-win32.phpt create mode 100644 ext/standard/tests/mail/mail_variation_alt3-win32.phpt diff --git a/ext/standard/tests/mail/ezmlm_hash_basic.phpt b/ext/standard/tests/mail/ezmlm_hash_basic.phpt new file mode 100644 index 00000000000..ce70eace232 --- /dev/null +++ b/ext/standard/tests/mail/ezmlm_hash_basic.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test ezmlm_hash() function : basic functionality +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECT-- +*** Testing ezmlm_hash() : basic functionality *** +int(1) +int(7) +===Done=== diff --git a/ext/standard/tests/mail/ezmlm_hash_basic_64bit.phpt b/ext/standard/tests/mail/ezmlm_hash_basic_64bit.phpt new file mode 100644 index 00000000000..cd791370c42 --- /dev/null +++ b/ext/standard/tests/mail/ezmlm_hash_basic_64bit.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test ezmlm_hash() function : basic functionality +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECT-- +*** Testing ezmlm_hash() : basic functionality *** +int(27) +int(48) +===Done=== diff --git a/ext/standard/tests/mail/ezmlm_hash_error.phpt b/ext/standard/tests/mail/ezmlm_hash_error.phpt new file mode 100644 index 00000000000..7170f7318ae --- /dev/null +++ b/ext/standard/tests/mail/ezmlm_hash_error.phpt @@ -0,0 +1,66 @@ +--TEST-- +Test ezmlm_hash() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing ezmlm_hash() : error conditions *** + +-- Testing ezmlm_hash() function with fewer than expected no. of arguments -- + +Warning: ezmlm_hash() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ezmlm_hash() function with more than expected no. of arguments -- + +Warning: ezmlm_hash() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +-- Testing ezmlm_hash() function with invalid input - ARRAY -- + +Warning: ezmlm_hash() expects parameter 1 to be binary string, array given in %s on line %d +NULL + +-- Testing ezmlm_hash() function with invalid input - OBJECT without 'cast_object' method -- + +Warning: ezmlm_hash() expects parameter 1 to be binary string, object given in %s on line %d +NULL + +-- Testing ezmlm_hash() function with invalid input - RESOURCE -- + +Warning: ezmlm_hash() expects parameter 1 to be binary string, resource given in %s on line %d +NULL +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/mail/ezmlm_hash_variation1.phpt b/ext/standard/tests/mail/ezmlm_hash_variation1.phpt new file mode 100644 index 00000000000..e263f7cad5b --- /dev/null +++ b/ext/standard/tests/mail/ezmlm_hash_variation1.phpt @@ -0,0 +1,193 @@ +--TEST-- +Test explode() function : usage variations - test values for $delimiter argument +--FILE-- + +===Done=== +--EXPECTF-- +*** Testing explode() function: with unexpected inputs for 'delimiter' argument *** +-- Iteration 1 -- +array(1) { + [0]=> + unicode(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 2 -- +array(2) { + [0]=> + unicode(5) "piece" + [1]=> + unicode(35) " piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 3 -- +array(1) { + [0]=> + unicode(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 4 -- +array(1) { + [0]=> + unicode(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 5 -- +array(1) { + [0]=> + unicode(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 6 -- +array(1) { + [0]=> + unicode(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 7 -- +array(1) { + [0]=> + unicode(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 8 -- +array(1) { + [0]=> + unicode(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 9 -- +array(1) { + [0]=> + unicode(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 10 -- + +Warning: explode() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: explode() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: explode() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- +array(2) { + [0]=> + unicode(5) "piece" + [1]=> + unicode(35) " piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 14 -- + +Warning: explode(): Empty delimiter in %s on line %d +bool(false) +-- Iteration 15 -- +array(2) { + [0]=> + unicode(5) "piece" + [1]=> + unicode(35) " piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 16 -- + +Warning: explode(): Empty delimiter in %s on line %d +bool(false) +-- Iteration 17 -- + +Warning: explode(): Empty delimiter in %s on line %d +bool(false) +-- Iteration 18 -- + +Warning: explode(): Empty delimiter in %s on line %d +bool(false) +-- Iteration 19 -- +array(1) { + [0]=> + unicode(41) "piece1 piece2 piece3 piece4 piece5 piece6" +} +-- Iteration 20 -- + +Warning: explode() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +-- Iteration 21 -- + +Warning: explode(): Empty delimiter in %s on line %d +bool(false) +-- Iteration 22 -- + +Warning: explode(): Empty delimiter in %s on line %d +bool(false) +===Done=== diff --git a/ext/standard/tests/mail/mail_basic.phpt b/ext/standard/tests/mail/mail_basic.phpt new file mode 100644 index 00000000000..77ff3512d86 --- /dev/null +++ b/ext/standard/tests/mail/mail_basic.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test mail() function : basic functionality +--INI-- +sendmail_path=tee mailBasic.out >/dev/null +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing mail() : basic functionality *** +-- All Mail Content Parameters -- +bool(true) +To: user@company.com +Subject: Test Subject +KHeaders + +A Message + +-- Mandatory Parameters -- +bool(true) +To: user@company.com +Subject: Test Subject + +A Message +===DONE=== diff --git a/ext/standard/tests/mail/mail_basic2.phpt b/ext/standard/tests/mail/mail_basic2.phpt new file mode 100644 index 00000000000..3e92479deb0 --- /dev/null +++ b/ext/standard/tests/mail/mail_basic2.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test mail() function : basic functionality +--INI-- +sendmail_path=echo --- > mailBasic2.out +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing mail() : basic functionality *** +-- extra parameters -- +bool(true) +--- Extras +===DONE=== diff --git a/ext/standard/tests/mail/mail_basic3.phpt b/ext/standard/tests/mail/mail_basic3.phpt new file mode 100644 index 00000000000..aad5e67d0cf --- /dev/null +++ b/ext/standard/tests/mail/mail_basic3.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test mail() function : basic functionality +--INI-- +sendmail_path="exit -1" +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing mail() : basic functionality *** +-- failure -- +bool(false) +===DONE=== diff --git a/ext/standard/tests/mail/mail_basic4.phpt b/ext/standard/tests/mail/mail_basic4.phpt new file mode 100644 index 00000000000..3956869a48e --- /dev/null +++ b/ext/standard/tests/mail/mail_basic4.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test mail() function : basic functionality +--INI-- +sendmail_path="exit -2" +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing mail() : basic functionality *** +-- failure -- +bool(false) +===DONE=== diff --git a/ext/standard/tests/mail/mail_basic5.phpt b/ext/standard/tests/mail/mail_basic5.phpt new file mode 100644 index 00000000000..7e42ccb8331 --- /dev/null +++ b/ext/standard/tests/mail/mail_basic5.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test mail() function : basic functionality +--INI-- +sendmail_path="exit 1" +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing mail() : basic functionality *** +-- failure -- +bool(false) +===DONE=== diff --git a/ext/standard/tests/mail/mail_basic_alt1-win32.phpt b/ext/standard/tests/mail/mail_basic_alt1-win32.phpt new file mode 100644 index 00000000000..3c4dd88a5b0 --- /dev/null +++ b/ext/standard/tests/mail/mail_basic_alt1-win32.phpt @@ -0,0 +1,95 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- + +--INI-- +max_execution_time = 120 +--FILE-- + 0) { + + // sleep for a while to allow msg to be delivered + sleep(1); + + $current_msg_count = imap_check($imap_stream)->Nmsgs; + + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); + + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } + + $repeat_count -= 1; +} + +if (!$found) { + echo "TEST FAILED: email not delivered\n"; +} else { + echo "TEST PASSED: Msgs sent and deleted OK\n"; +} + +imap_close($imap_stream, CL_EXPUNGE); +?> +===Done=== +--EXPECTF-- +*** Testing mail() : basic functionality *** +Msg sent OK +Id of msg just sent is %d +.. delete it +TEST PASSED: Msgs sent and deleted OK +===Done=== diff --git a/ext/standard/tests/mail/mail_basic_alt2-win32.phpt b/ext/standard/tests/mail/mail_basic_alt2-win32.phpt new file mode 100644 index 00000000000..d7bae62a0ff --- /dev/null +++ b/ext/standard/tests/mail/mail_basic_alt2-win32.phpt @@ -0,0 +1,93 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- + +--INI-- +max_execution_time = 120 +--FILE-- + 0) { + + // sleep for a while to allow msg to be delivered + sleep(1); + + $current_msg_count = imap_check($imap_stream)->Nmsgs; + + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); + + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } + + $repeat_count -= 1; +} + +if (!$found) { + echo "TEST FAILED: email not delivered\n"; +} else { + echo "TEST PASSED: Msgs sent and deleted OK\n"; +} + +imap_close($imap_stream, CL_EXPUNGE); +?> +===Done=== +--EXPECTF-- +*** Testing mail() : basic functionality *** +Msg sent OK +Id of msg just sent is %d +.. delete it +TEST PASSED: Msgs sent and deleted OK +===Done=== diff --git a/ext/standard/tests/mail/mail_basic_alt3-win32.phpt b/ext/standard/tests/mail/mail_basic_alt3-win32.phpt new file mode 100644 index 00000000000..86b57eb8138 --- /dev/null +++ b/ext/standard/tests/mail/mail_basic_alt3-win32.phpt @@ -0,0 +1,93 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- + +--INI-- +max_execution_time = 120 +--FILE-- + 0) { + + // sleep for a while to allow msg to be delivered + sleep(1); + + $current_msg_count = imap_check($imap_stream)->Nmsgs; + + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); + + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } + + $repeat_count -= 1; +} + +if (!$found) { + echo "TEST FAILED: email not delivered\n"; +} else { + echo "TEST PASSED: Msgs sent and deleted OK\n"; +} + +imap_close($imap_stream, CL_EXPUNGE); +?> +===Done=== +--EXPECTF-- +*** Testing mail() : basic functionality *** +Msg sent OK +Id of msg just sent is %d +.. delete it +TEST PASSED: Msgs sent and deleted OK +===Done=== diff --git a/ext/standard/tests/mail/mail_basic_alt4-win32.phpt b/ext/standard/tests/mail/mail_basic_alt4-win32.phpt new file mode 100644 index 00000000000..f4a9d466bc7 --- /dev/null +++ b/ext/standard/tests/mail/mail_basic_alt4-win32.phpt @@ -0,0 +1,94 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- + +--INI-- +max_execution_time = 120 +--FILE-- + 0) { + + // sleep for a while to allow msg to be delivered + sleep(1); + + $current_msg_count = imap_check($imap_stream)->Nmsgs; + + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); + + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } + + $repeat_count -= 1; +} + +if (!$found) { + echo "TEST FAILED: email not delivered\n"; +} else { + echo "TEST PASSED: Msgs sent and deleted OK\n"; +} + +imap_close($imap_stream, CL_EXPUNGE); +?> +===Done=== +--EXPECTF-- +*** Testing mail() : basic functionality *** +Msg sent OK +Id of msg just sent is %d +.. delete it +TEST PASSED: Msgs sent and deleted OK +===Done=== diff --git a/ext/standard/tests/mail/mail_error.phpt b/ext/standard/tests/mail/mail_error.phpt new file mode 100644 index 00000000000..871b6da0be4 --- /dev/null +++ b/ext/standard/tests/mail/mail_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test mail() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing mail() : error conditions *** + +-- Testing mail() function with more than expected no. of arguments -- + +Warning: mail() expects at most 5 parameters, 6 given in %s on line %d +NULL + +-- Testing mail() function with less than expected no. of arguments -- + +Warning: mail() expects at least 3 parameters, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/standard/tests/mail/mail_include.inc b/ext/standard/tests/mail/mail_include.inc new file mode 100644 index 00000000000..a93187871d4 --- /dev/null +++ b/ext/standard/tests/mail/mail_include.inc @@ -0,0 +1,150 @@ +name == $mailbox) { + exit ("TEST FAILED : Mailbox '$mailbox' already exists\n"); + } + } + } + + if (imap_createmailbox($imap_stream, $mailbox) === false) { + return false; + } + + // Add number of test msgs requested + if ($message_count > 0) { + populate_mailbox($imap_stream, $mailbox, $message_count, $msg_type); + } + + return $mailbox; +} + +/** + * Populate a mailbox with generic emails + * + * @param resource $imap_stream + * @param string $mailbox + */ +function populate_mailbox($imap_stream, $mailbox, $message_count, $msg_type = "simple"){ + + global $users, $domain; + + for($i = 1; $i <= $message_count; $i++) { + if ($msg_type == "simple") { + $msg = "From: foo@anywhere.com\r\n" + . "To: $users[0]@$domain\r\n" + . "Subject: test$i\r\n" + . "\r\n" + . "$i: this is a test message, please ignore\r\n"; + } else { + $envelope["from"]= "foo@anywhere.com"; + $envelope["to"] = "$users[0]@$domain"; + $envelope["subject"] = "Test msg $i"; + + $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"; + + $part4["type"] = TYPETEXT; + $part4["subtype"] = "plain"; + $part4["description"] = "Return Values"; + $part4["contents.data"] = "message 3:zzzzzzzzzzzzzzzzzzzzzzzzzz"; + + $body[1] = $part1; + $body[2] = $part2; + $body[3] = $part3; + $body[4] = $part4; + + $msg = imap_mail_compose($envelope, $body); + } + + imap_append($imap_stream, $mailbox, $msg); + } +} + +/** + * Get the mailbox name from a mailbox decription, i.e strip off server details. + * + * @param string mailbox complete mailbox name + * @return mailbox name + */ +function get_mailbox_name($mailbox){ + + if (preg_match('/\{.*?\}(.*)/', $mailbox, $match) != 1) { + echo "Unrecpognized mailbox name\n"; + return false; + } + + return $match[1]; +} + +?> \ No newline at end of file diff --git a/ext/standard/tests/mail/mail_skipif.inc b/ext/standard/tests/mail/mail_skipif.inc new file mode 100644 index 00000000000..d01fcd986f3 --- /dev/null +++ b/ext/standard/tests/mail/mail_skipif.inc @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/ext/standard/tests/mail/mail_variation1.phpt b/ext/standard/tests/mail/mail_variation1.phpt new file mode 100644 index 00000000000..bf37bf41e62 --- /dev/null +++ b/ext/standard/tests/mail/mail_variation1.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test mail() function : variation invalid program for sendmail +--INI-- +sendmail_path=rubbish 2>/dev/null +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing mail() : variation *** +bool(false) +===DONE=== diff --git a/ext/standard/tests/mail/mail_variation2.phpt b/ext/standard/tests/mail/mail_variation2.phpt new file mode 100644 index 00000000000..1a0fcc69d05 --- /dev/null +++ b/ext/standard/tests/mail/mail_variation2.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test mail() function : variation force extra parameters +--INI-- +sendmail_path=echo --- > mailBasic2.out +mail.force_extra_parameters="forced params" +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing mail() : basic functionality *** +bool(true) +--- forced params +===DONE=== diff --git a/ext/standard/tests/mail/mail_variation_alt1-win32.phpt b/ext/standard/tests/mail/mail_variation_alt1-win32.phpt new file mode 100644 index 00000000000..b81f3af9d2d --- /dev/null +++ b/ext/standard/tests/mail/mail_variation_alt1-win32.phpt @@ -0,0 +1,92 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- + +--INI-- +max_execution_time = 120 +--FILE-- + 0) { + + // sleep for a while to allow msg to be delivered + sleep(1); + + $current_msg_count = imap_check($imap_stream)->Nmsgs; + + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); + + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } + + $repeat_count -= 1; +} + +if (!$found) { + echo "TEST FAILED: email not delivered\n"; +} else { + echo "TEST PASSED: Msgs sent and deleted OK\n"; +} + +imap_close($imap_stream, CL_EXPUNGE); +?> +===Done=== +--EXPECTF-- +*** Testing mail() : basic functionality *** + +Warning: mail(): Failed to connect to mailserver at "localhost" port 2525, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in %s on line %d +TEST COMPLETED : Unable to send test email diff --git a/ext/standard/tests/mail/mail_variation_alt2-win32.phpt b/ext/standard/tests/mail/mail_variation_alt2-win32.phpt new file mode 100644 index 00000000000..6ae06bb202a --- /dev/null +++ b/ext/standard/tests/mail/mail_variation_alt2-win32.phpt @@ -0,0 +1,92 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- + +--INI-- +max_execution_time = 120 +--FILE-- + 0) { + + // sleep for a while to allow msg to be delivered + sleep(1); + + $current_msg_count = imap_check($imap_stream)->Nmsgs; + + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); + + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } + + $repeat_count -= 1; +} + +if (!$found) { + echo "TEST FAILED: email not delivered\n"; +} else { + echo "TEST PASSED: Msgs sent and deleted OK\n"; +} + +imap_close($imap_stream, CL_EXPUNGE); +?> +===Done=== +--EXPECTF-- +*** Testing mail() : basic functionality *** + +Warning: mail(): Failed to connect to mailserver at "localplace" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in %s on line %d +TEST COMPLETED : Unable to send test email diff --git a/ext/standard/tests/mail/mail_variation_alt3-win32.phpt b/ext/standard/tests/mail/mail_variation_alt3-win32.phpt new file mode 100644 index 00000000000..4062fae9818 --- /dev/null +++ b/ext/standard/tests/mail/mail_variation_alt3-win32.phpt @@ -0,0 +1,91 @@ +--TEST-- +Test mail() function : basic functionality +--SKIPIF-- + +--INI-- +max_execution_time = 120 +--FILE-- + 0) { + + // sleep for a while to allow msg to be delivered + sleep(1); + + $current_msg_count = imap_check($imap_stream)->Nmsgs; + + // Iterate over recent msgs to find the one we sent above + for ($i = 1; $i <= $current_msg_count; $i++) { + // get hdr details + $hdr = imap_headerinfo($imap_stream, $i); + + if (substr($hdr->Subject, 0 , strlen($subject_prefix)) == $subject_prefix) { + echo "Id of msg just sent is $i\n"; + echo ".. delete it\n"; + imap_delete($imap_stream, $i); + $found = true; + break; + } + } + + $repeat_count -= 1; +} + +if (!$found) { + echo "TEST FAILED: email not delivered\n"; +} else { + echo "TEST PASSED: Msgs sent and deleted OK\n"; +} + +imap_close($imap_stream, CL_EXPUNGE); +?> +===Done=== +--EXPECTF-- +*** Testing mail() : basic functionality *** + +Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in %s on line %d +TEST COMPLETED : Unable to send test email