diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-02-03 22:52:20 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-02-03 22:52:20 +0100 |
commit | f8d795820e780a6322e054c26c581570613c14f0 (patch) | |
tree | 99d3ae01ce564752807341c5743863b4c92513f8 /ext/standard/tests/mail | |
parent | d2cb200e10ada6fa44c54a29292bb4665728fff0 (diff) | |
download | php-git-f8d795820e780a6322e054c26c581570613c14f0.tar.gz |
Reindent phpt files
Diffstat (limited to 'ext/standard/tests/mail')
-rw-r--r-- | ext/standard/tests/mail/mail_basic7.phpt | 64 | ||||
-rw-r--r-- | ext/standard/tests/mail/mail_basic_alt1-win32.phpt | 44 | ||||
-rw-r--r-- | ext/standard/tests/mail/mail_basic_alt2-win32.phpt | 44 | ||||
-rw-r--r-- | ext/standard/tests/mail/mail_basic_alt3-win32.phpt | 44 | ||||
-rw-r--r-- | ext/standard/tests/mail/mail_basic_alt4-win32.phpt | 44 | ||||
-rw-r--r-- | ext/standard/tests/mail/mail_include.inc | 182 | ||||
-rw-r--r-- | ext/standard/tests/mail/mail_log.phpt | 2 | ||||
-rw-r--r-- | ext/standard/tests/mail/mail_skipif.inc | 16 | ||||
-rw-r--r-- | ext/standard/tests/mail/mail_variation_alt1-win32.phpt | 44 | ||||
-rw-r--r-- | ext/standard/tests/mail/mail_variation_alt2-win32.phpt | 44 | ||||
-rw-r--r-- | ext/standard/tests/mail/mail_variation_alt3-win32.phpt | 44 |
11 files changed, 286 insertions, 286 deletions
diff --git a/ext/standard/tests/mail/mail_basic7.phpt b/ext/standard/tests/mail/mail_basic7.phpt index c01fb5fe25..9c9c61d835 100644 --- a/ext/standard/tests/mail/mail_basic7.phpt +++ b/ext/standard/tests/mail/mail_basic7.phpt @@ -22,13 +22,13 @@ $to = 'user@example.com'; $subject = 'Test Subject'; $message = 'A Message'; $additional_headers = array( - 'KHeaders' => 'aaaa', - 'bcc'=>'foo@bar', - 'foo'=> - array( - "bar\r\n hoge", - "bar\r\n\t fuga", - ), + 'KHeaders' => 'aaaa', + 'bcc'=>'foo@bar', + 'foo'=> + array( + "bar\r\n hoge", + "bar\r\n\t fuga", + ), ); $outFile = "mailBasic7.out"; @unlink($outFile); @@ -48,14 +48,14 @@ $subject = 'Test Subject'; $message = 'A Message'; // Headers should not have array values $additional_headers = array( - 'orig-date' => array('foo1'), - 'from' => array('foo2'), - 'sender' => array('foo3'), - 'reply-to' => array('foo4'), - 'to' => array('foo5'), - 'bcc' => array('foo6'), - 'message-id' => array('foo7'), - 'in-reply-to'=> array('foo8'), + 'orig-date' => array('foo1'), + 'from' => array('foo2'), + 'sender' => array('foo3'), + 'reply-to' => array('foo4'), + 'to' => array('foo5'), + 'bcc' => array('foo6'), + 'message-id' => array('foo7'), + 'in-reply-to'=> array('foo8'), ); $outFile = "mailBasic7.out"; @unlink($outFile); @@ -74,13 +74,13 @@ $to = 'user@example.com'; $subject = 'Test Subject'; $message = 'A Message'; $additional_headers = array( - 'foo1' => array('foo1'=>'bar1'), - 'foo2' => array('foo2', array('foo3')), - 'foo3' => array(123), - 'foo4' => array(123.456), - 'foo5' => array(FALSE), - 'foo6' => array(NULL), - 'foo7' => array(new StdClass), + 'foo1' => array('foo1'=>'bar1'), + 'foo2' => array('foo2', array('foo3')), + 'foo3' => array(123), + 'foo4' => array(123.456), + 'foo5' => array(FALSE), + 'foo6' => array(NULL), + 'foo7' => array(new StdClass), ); $outFile = "mailBasic7.out"; @unlink($outFile); @@ -99,16 +99,16 @@ $to = 'user@example.com'; $subject = 'Test Subject'; $message = 'A Message'; $additional_headers = array( - '*:foo1' => array('bar1'), - 'foo2:::' => array('bar1'), - 'foo3()' => array('bar1'), - 'foo4@' => array('bar1'), - 'foo5|' => array('bar1'), - "\0foo6" => array('bar1'), - "foo7\0" => array('bar1'), - "foo8" => array(), - "foo9" => '%&$#!', - "foo10" => "abc\0\tdef", + '*:foo1' => array('bar1'), + 'foo2:::' => array('bar1'), + 'foo3()' => array('bar1'), + 'foo4@' => array('bar1'), + 'foo5|' => array('bar1'), + "\0foo6" => array('bar1'), + "foo7\0" => array('bar1'), + "foo8" => array(), + "foo9" => '%&$#!', + "foo10" => "abc\0\tdef", ); $outFile = "mailBasic7.out"; @unlink($outFile); diff --git a/ext/standard/tests/mail/mail_basic_alt1-win32.phpt b/ext/standard/tests/mail/mail_basic_alt1-win32.phpt index c48634e99c..5952a14f59 100644 --- a/ext/standard/tests/mail/mail_basic_alt1-win32.phpt +++ b/ext/standard/tests/mail/mail_basic_alt1-win32.phpt @@ -38,48 +38,48 @@ HERE; $res = mail($to, $subject, $message); if ($res !== true) { - exit("TEST FAILED : Unable to send test email\n"); + exit("TEST FAILED : Unable to send test email\n"); } else { - echo "Msg sent OK\n"; + echo "Msg sent OK\n"; } // Search for email message on the mail server using imap. $imap_stream = imap_open($default_mailbox, $username, $password); if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; } $found = false; $repeat_count = 20; // we will repeat a max of 20 times while (!$found && $repeat_count > 0) { - // sleep for a while to allow msg to be delivered - sleep(1); + // sleep for a while to allow msg to be delivered + sleep(1); - $current_msg_count = imap_check($imap_stream)->Nmsgs; + $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); + // 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; - } - } + 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; + $repeat_count -= 1; } if (!$found) { - echo "TEST FAILED: email not delivered\n"; + echo "TEST FAILED: email not delivered\n"; } else { - echo "TEST PASSED: Msgs sent and deleted OK\n"; + echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); diff --git a/ext/standard/tests/mail/mail_basic_alt2-win32.phpt b/ext/standard/tests/mail/mail_basic_alt2-win32.phpt index 3aff59a614..8c7a28983c 100644 --- a/ext/standard/tests/mail/mail_basic_alt2-win32.phpt +++ b/ext/standard/tests/mail/mail_basic_alt2-win32.phpt @@ -35,48 +35,48 @@ $extra_headers = "from: user@example.com"; $res = mail($to, $subject, $message, $extra_headers); if ($res !== true) { - exit("TEST FAILED : Unable to send test email\n"); + exit("TEST FAILED : Unable to send test email\n"); } else { - echo "Msg sent OK\n"; + echo "Msg sent OK\n"; } // Search for email message on the mail server using imap. $imap_stream = imap_open($default_mailbox, $username, $password); if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; } $found = false; $repeat_count = 20; // we will repeat a max of 20 times while (!$found && $repeat_count > 0) { - // sleep for a while to allow msg to be delivered - sleep(1); + // sleep for a while to allow msg to be delivered + sleep(1); - $current_msg_count = imap_check($imap_stream)->Nmsgs; + $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); + // 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; - } - } + 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; + $repeat_count -= 1; } if (!$found) { - echo "TEST FAILED: email not delivered\n"; + echo "TEST FAILED: email not delivered\n"; } else { - echo "TEST PASSED: Msgs sent and deleted OK\n"; + echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); diff --git a/ext/standard/tests/mail/mail_basic_alt3-win32.phpt b/ext/standard/tests/mail/mail_basic_alt3-win32.phpt index 52d48937ed..15fb701e28 100644 --- a/ext/standard/tests/mail/mail_basic_alt3-win32.phpt +++ b/ext/standard/tests/mail/mail_basic_alt3-win32.phpt @@ -35,48 +35,48 @@ $extra_headers = "FRom: user@example.com"; $res = mail($to, $subject, $message, $extra_headers); if ($res !== true) { - exit("TEST FAILED : Unable to send test email\n"); + exit("TEST FAILED : Unable to send test email\n"); } else { - echo "Msg sent OK\n"; + echo "Msg sent OK\n"; } // Search for email message on the mail server using imap. $imap_stream = imap_open($default_mailbox, $username, $password); if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; } $found = false; $repeat_count = 20; // we will repeat a max of 20 times while (!$found && $repeat_count > 0) { - // sleep for a while to allow msg to be delivered - sleep(1); + // sleep for a while to allow msg to be delivered + sleep(1); - $current_msg_count = imap_check($imap_stream)->Nmsgs; + $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); + // 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; - } - } + 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; + $repeat_count -= 1; } if (!$found) { - echo "TEST FAILED: email not delivered\n"; + echo "TEST FAILED: email not delivered\n"; } else { - echo "TEST PASSED: Msgs sent and deleted OK\n"; + echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); diff --git a/ext/standard/tests/mail/mail_basic_alt4-win32.phpt b/ext/standard/tests/mail/mail_basic_alt4-win32.phpt index a677312442..96c6fb11f5 100644 --- a/ext/standard/tests/mail/mail_basic_alt4-win32.phpt +++ b/ext/standard/tests/mail/mail_basic_alt4-win32.phpt @@ -36,48 +36,48 @@ $extra_parameters = "addons"; // should be ignored $res = mail($to, $subject, $message, $extra_headers, $extra_parameters); if ($res !== true) { - exit("TEST FAILED : Unable to send test email\n"); + exit("TEST FAILED : Unable to send test email\n"); } else { - echo "Msg sent OK\n"; + echo "Msg sent OK\n"; } // Search for email message on the mail server using imap. $imap_stream = imap_open($default_mailbox, $username, $password); if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; } $found = false; $repeat_count = 20; // we will repeat a max of 20 times while (!$found && $repeat_count > 0) { - // sleep for a while to allow msg to be delivered - sleep(1); + // sleep for a while to allow msg to be delivered + sleep(1); - $current_msg_count = imap_check($imap_stream)->Nmsgs; + $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); + // 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; - } - } + 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; + $repeat_count -= 1; } if (!$found) { - echo "TEST FAILED: email not delivered\n"; + echo "TEST FAILED: email not delivered\n"; } else { - echo "TEST PASSED: Msgs sent and deleted OK\n"; + echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); diff --git a/ext/standard/tests/mail/mail_include.inc b/ext/standard/tests/mail/mail_include.inc index ba7ee121b5..c69d4a7182 100644 --- a/ext/standard/tests/mail/mail_include.inc +++ b/ext/standard/tests/mail/mail_include.inc @@ -18,32 +18,32 @@ $mailbox_prefix = "phpttest"; // name used for test mailbox * @return IMAP stream to new mailbox on success; FALSE on failure */ function setup_test_mailbox($mailbox_suffix, $message_count, &$new_mailbox = null, $msg_type = "simple"){ - global $server, $default_mailbox, $username, $password; + global $server, $default_mailbox, $username, $password; - // open a stream to default mailbox - $imap_stream = imap_open($default_mailbox, $username, $password); + // open a stream to default mailbox + $imap_stream = imap_open($default_mailbox, $username, $password); - if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; - } + if ($imap_stream === false) { + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; + } - echo "Create a temporary mailbox and add " . $message_count . " msgs\n"; - $new_mailbox = create_mailbox($imap_stream, $mailbox_suffix, $message_count, $msg_type); - if ($new_mailbox === false) { - echo "Can't create a temporary mailbox: " . imap_last_error(). "\n"; - return false; - } + echo "Create a temporary mailbox and add " . $message_count . " msgs\n"; + $new_mailbox = create_mailbox($imap_stream, $mailbox_suffix, $message_count, $msg_type); + if ($new_mailbox === false) { + echo "Can't create a temporary mailbox: " . imap_last_error(). "\n"; + return false; + } - echo ".. mailbox '$new_mailbox' created\n"; + echo ".. mailbox '$new_mailbox' created\n"; - // reopen stream to new mailbox - if (imap_reopen($imap_stream, $new_mailbox) === false) { - echo "can't re-open '$new_mailbox' mailbox: " . imap_last_error() . "\n"; - return false; - } + // reopen stream to new mailbox + if (imap_reopen($imap_stream, $new_mailbox) === false) { + echo "can't re-open '$new_mailbox' mailbox: " . imap_last_error() . "\n"; + return false; + } - return $imap_stream; + return $imap_stream; } /** @@ -53,30 +53,30 @@ function setup_test_mailbox($mailbox_suffix, $message_count, &$new_mailbox = nul * @param string $mailbox */ function create_mailbox($imap_stream, $mailbox_suffix, $message_count, $msg_type= "simple"){ - global $default_mailbox, $mailbox_prefix; - $mailbox = $default_mailbox . "." . $mailbox_prefix . $mailbox_suffix; - - $mailboxes = imap_getmailboxes($imap_stream, $mailbox, '*'); - - // check mailbox does not already exist - if ($mailboxes) { - foreach($mailboxes as $value) { - if ($value->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; + global $default_mailbox, $mailbox_prefix; + $mailbox = $default_mailbox . "." . $mailbox_prefix . $mailbox_suffix; + + $mailboxes = imap_getmailboxes($imap_stream, $mailbox, '*'); + + // check mailbox does not already exist + if ($mailboxes) { + foreach($mailboxes as $value) { + if ($value->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; } /** @@ -87,48 +87,48 @@ function create_mailbox($imap_stream, $mailbox_suffix, $message_count, $msg_type */ 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); - } + 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); + } } /** @@ -139,12 +139,12 @@ function populate_mailbox($imap_stream, $mailbox, $message_count, $msg_type = "s */ function get_mailbox_name($mailbox){ - if (preg_match('/\{.*?\}(.*)/', $mailbox, $match) != 1) { - echo "Unrecpognized mailbox name\n"; - return false; - } + if (preg_match('/\{.*?\}(.*)/', $mailbox, $match) != 1) { + echo "Unrecpognized mailbox name\n"; + return false; + } - return $match[1]; + return $match[1]; } ?> diff --git a/ext/standard/tests/mail/mail_log.phpt b/ext/standard/tests/mail/mail_log.phpt index e60aa621b0..4f9e9423f4 100644 --- a/ext/standard/tests/mail/mail_log.phpt +++ b/ext/standard/tests/mail/mail_log.phpt @@ -9,7 +9,7 @@ date_default_timezone_set("UTC"); $logfile = ini_get("mail.log"); if (file_exists($logfile)) { - unlink($logfile); + unlink($logfile); } touch($logfile); clearstatcache(); diff --git a/ext/standard/tests/mail/mail_skipif.inc b/ext/standard/tests/mail/mail_skipif.inc index fedcfbbe4e..8f2468581d 100644 --- a/ext/standard/tests/mail/mail_skipif.inc +++ b/ext/standard/tests/mail/mail_skipif.inc @@ -2,13 +2,13 @@ extension_loaded('imap') or die('skip imap extension not available in this build'); if( substr(PHP_OS, 0, 3) == 'WIN' && extension_loaded('sockets')) { - // be sure mail server is accessible... on PHP 5.3.13 release build, using test-pack PHP-5.3-r1af8b3f, - // the code below didn't skip test even though there was no mail server - // test then failed (no mail server to test against) - $socket = socket_create(AF_INET, SOCK_RAW, 1); - socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 10, 'usec' => 10)); - // imap uses tcp port 143 - socket_connect($socket, "localhost", 143) or die ("skip can't socket to mail server"); + // be sure mail server is accessible... on PHP 5.3.13 release build, using test-pack PHP-5.3-r1af8b3f, + // the code below didn't skip test even though there was no mail server + // test then failed (no mail server to test against) + $socket = socket_create(AF_INET, SOCK_RAW, 1); + socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 10, 'usec' => 10)); + // imap uses tcp port 143 + socket_connect($socket, "localhost", 143) or die ("skip can't socket to mail server"); } // Change these to make tests run successfully @@ -20,7 +20,7 @@ $retries = 0; // don't retry connect on failure $mbox = imap_open($mailbox, $username, $password, $options, $retries); if (!$mbox) { - die("skip could not connect to mailbox $mailbox"); + die("skip could not connect to mailbox $mailbox"); } imap_close($mbox); ?> diff --git a/ext/standard/tests/mail/mail_variation_alt1-win32.phpt b/ext/standard/tests/mail/mail_variation_alt1-win32.phpt index 92a59477d0..155dc9815a 100644 --- a/ext/standard/tests/mail/mail_variation_alt1-win32.phpt +++ b/ext/standard/tests/mail/mail_variation_alt1-win32.phpt @@ -37,48 +37,48 @@ HERE; $res = mail($to, $subject, $message); if ($res !== true) { - exit("TEST COMPLETED : Unable to send test email\n"); + exit("TEST COMPLETED : Unable to send test email\n"); } else { - echo "Msg sent OK\n"; + echo "Msg sent OK\n"; } // Search for email message on the mail server using imap. $imap_stream = imap_open($default_mailbox, $username, $password); if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; } $found = false; $repeat_count = 20; // we will repeat a max of 20 times while (!$found && $repeat_count > 0) { - // sleep for a while to allow msg to be delivered - sleep(1); + // sleep for a while to allow msg to be delivered + sleep(1); - $current_msg_count = imap_check($imap_stream)->Nmsgs; + $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); + // 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; - } - } + 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; + $repeat_count -= 1; } if (!$found) { - echo "TEST FAILED: email not delivered\n"; + echo "TEST FAILED: email not delivered\n"; } else { - echo "TEST PASSED: Msgs sent and deleted OK\n"; + echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); diff --git a/ext/standard/tests/mail/mail_variation_alt2-win32.phpt b/ext/standard/tests/mail/mail_variation_alt2-win32.phpt index 06c16eb5f8..36d971329f 100644 --- a/ext/standard/tests/mail/mail_variation_alt2-win32.phpt +++ b/ext/standard/tests/mail/mail_variation_alt2-win32.phpt @@ -37,48 +37,48 @@ HERE; $res = mail($to, $subject, $message); if ($res !== true) { - exit("TEST COMPLETED : Unable to send test email\n"); + exit("TEST COMPLETED : Unable to send test email\n"); } else { - echo "Msg sent OK\n"; + echo "Msg sent OK\n"; } // Search for email message on the mail server using imap. $imap_stream = imap_open($default_mailbox, $username, $password); if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; } $found = false; $repeat_count = 20; // we will repeat a max of 20 times while (!$found && $repeat_count > 0) { - // sleep for a while to allow msg to be delivered - sleep(1); + // sleep for a while to allow msg to be delivered + sleep(1); - $current_msg_count = imap_check($imap_stream)->Nmsgs; + $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); + // 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; - } - } + 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; + $repeat_count -= 1; } if (!$found) { - echo "TEST FAILED: email not delivered\n"; + echo "TEST FAILED: email not delivered\n"; } else { - echo "TEST PASSED: Msgs sent and deleted OK\n"; + echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); diff --git a/ext/standard/tests/mail/mail_variation_alt3-win32.phpt b/ext/standard/tests/mail/mail_variation_alt3-win32.phpt index 44eda4555b..96d5d796bb 100644 --- a/ext/standard/tests/mail/mail_variation_alt3-win32.phpt +++ b/ext/standard/tests/mail/mail_variation_alt3-win32.phpt @@ -36,48 +36,48 @@ HERE; $res = mail($to, $subject, $message); if ($res !== true) { - exit("TEST COMPLETED : Unable to send test email\n"); + exit("TEST COMPLETED : Unable to send test email\n"); } else { - echo "Msg sent OK\n"; + echo "Msg sent OK\n"; } // Search for email message on the mail server using imap. $imap_stream = imap_open($default_mailbox, $username, $password); if ($imap_stream === false) { - echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; - return false; + echo "Cannot connect to IMAP server $server: " . imap_last_error() . "\n"; + return false; } $found = false; $repeat_count = 20; // we will repeat a max of 20 times while (!$found && $repeat_count > 0) { - // sleep for a while to allow msg to be delivered - sleep(1); + // sleep for a while to allow msg to be delivered + sleep(1); - $current_msg_count = imap_check($imap_stream)->Nmsgs; + $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); + // 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; - } - } + 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; + $repeat_count -= 1; } if (!$found) { - echo "TEST FAILED: email not delivered\n"; + echo "TEST FAILED: email not delivered\n"; } else { - echo "TEST PASSED: Msgs sent and deleted OK\n"; + echo "TEST PASSED: Msgs sent and deleted OK\n"; } imap_close($imap_stream, CL_EXPUNGE); |