Skip to content

Commit d2bb59c

Browse files
committed
Test standard mail and imap on Windows CI
We setup the currently latest version of hMailServer[1] as mail server, and configure according to imap_include.inc. To not require further configuration, we adapt mail_skipif.inc and mail_include.inc to match that configuration. However, we also change the default domain to the reserved `example.com`. We also update the standard mail tests to use the `--EXTENSIONS--` section (instead of skipping the tests if ext/imap is not available). Finally, we fix bug80751.phpt to expect the configured To and Cc mail addresses. [1] <https://www.hmailserver.com/> Closes GH-8357.
1 parent 81d1a1b commit d2bb59c

17 files changed

+61
-15
lines changed

appveyor/setup_hmailserver.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
require __DIR__ . "/../ext/imap/tests/setup/imap_include.inc";
4+
5+
$hmail = new COM("hMailServer.Application");
6+
$hmail->authenticate("Administrator", "");
7+
8+
$domain = $hmail->Domains->Add();
9+
$domain->Name = IMAP_MAIL_DOMAIN;
10+
$domain->Active = true;
11+
$domain->Save();
12+
13+
$accounts = $domain->accounts();
14+
15+
foreach (IMAP_USERS as $user) {
16+
$account = $accounts->Add();
17+
$account->Address = "$user@" . IMAP_MAIL_DOMAIN;
18+
$account->Password = IMAP_MAILBOX_PASSWORD;
19+
$account->Active = true;
20+
$account->Save();
21+
}

appveyor/test_task.bat

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ start %DEPS_DIR%\bin\snmpd.exe -C -c %APPVEYOR_BUILD_FOLDER%\ext\snmp\tests\snmp
9696
set PHP_BUILD_DIR=%PHP_BUILD_OBJ_DIR%\Release
9797
if "%THREAD_SAFE%" equ "1" set PHP_BUILD_DIR=%PHP_BUILD_DIR%_TS
9898

99+
rem prepare for mail
100+
curl -sLo hMailServer.exe https://www.hmailserver.com/download_file/?downloadid=271
101+
hMailServer.exe /verysilent
102+
cd %APPVEYOR_BUILD_FOLDER%
103+
%PHP_BUILD_DIR%\php.exe -dextension_dir=%PHP_BUILD_DIR% -dextension=com_dotnet appveyor\setup_hmailserver.php
104+
99105
mkdir %PHP_BUILD_DIR%\test_file_cache
100106
rem generate php.ini
101107
echo extension_dir=%PHP_BUILD_DIR% > %PHP_BUILD_DIR%\php.ini
@@ -105,7 +111,7 @@ rem work-around for some spawned PHP processes requiring OpenSSL
105111
echo extension=php_openssl.dll >> %PHP_BUILD_DIR%\php.ini
106112

107113
rem remove ext dlls for which tests are not supported
108-
for %%i in (imap ldap oci8_12c pdo_firebird pdo_oci) do (
114+
for %%i in (ldap oci8_12c pdo_firebird pdo_oci) do (
109115
del %PHP_BUILD_DIR%\php_%%i.dll
110116
)
111117

ext/imap/tests/imap_append_basic.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ $imap_stream = setup_test_mailbox("imapappendbaisc", 0);
1818
$mb_details = imap_mailboxmsginfo($imap_stream);
1919
echo "Add a couple of msgs to the new mailbox\n";
2020
var_dump(imap_append($imap_stream, $mb_details->Mailbox
21-
, "From: webmaster@something.com\r\n"
22-
. "To: info@something.com\r\n"
21+
, "From: webmaster@example.com\r\n"
22+
. "To: info@example.com\r\n"
2323
. "Subject: Test message\r\n"
2424
. "\r\n"
2525
. "this is a test message, please ignore\r\n"
2626
));
2727

2828
var_dump(imap_append($imap_stream, $mb_details->Mailbox
29-
, "From: webmaster@something.com\r\n"
30-
. "To: info@something.com\r\n"
29+
, "From: webmaster@example.com\r\n"
30+
. "To: info@example.com\r\n"
3131
. "Subject: Another test\r\n"
3232
. "\r\n"
3333
. "this is another test message, please ignore it too!!\r\n"
@@ -58,7 +58,7 @@ Msg Count after append : 2
5858
List the msg headers
5959
array(2) {
6060
[0]=>
61-
string(%d) "%w%s 1)%s webmaster@something. Test message (%d chars)"
61+
string(%d) "%w%s 1)%s webmaster@example.co Test message (%d chars)"
6262
[1]=>
63-
string(%d) "%w%s 2)%s webmaster@something. Another test (%d chars)"
63+
string(%d) "%w%s 2)%s webmaster@example.co Another test (%d chars)"
6464
}

ext/imap/tests/setup/dovecotpass

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
webmaster@something.com:{CRAM-MD5}be5f3177e9c7c06403272f25d983ba630df4ef40476b353bb3087a8401713451:vmail:vmail
1+
webmaster@example.com:{CRAM-MD5}be5f3177e9c7c06403272f25d983ba630df4ef40476b353bb3087a8401713451:vmail:vmail

ext/imap/tests/setup/imap_include.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const IMAP_SERVER_NO_DEBUG = '{127.0.0.1:143/norsh}';
44
const IMAP_SERVER_DEBUG = '{127.0.0.1:143/debug/norsh}';
55
const IMAP_SERVER = IMAP_SERVER_DEBUG;
66
const IMAP_DEFAULT_MAILBOX = IMAP_SERVER . 'INBOX';
7-
const IMAP_MAIL_DOMAIN = 'something.com';
7+
const IMAP_MAIL_DOMAIN = 'example.com';
88
const IMAP_ADMIN_USER = 'webmaster'; // a user with admin access
99
const IMAP_MAILBOX_USERNAME = IMAP_ADMIN_USER . '@' . IMAP_MAIL_DOMAIN;
1010
const IMAP_MAILBOX_PASSWORD = 'p4ssw0rd';

ext/standard/tests/mail/bug72964.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Bug #72964 (White space not unfolded for CC/Bcc headers)
3+
--EXTENSIONS--
4+
imap
35
--SKIPIF--
46
<?php
57
if (PHP_OS_FAMILY !== 'Windows') die('skip Windows only test');

ext/standard/tests/mail/bug80706.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Bug #72964 (White space not unfolded for CC/Bcc headers)
3+
--EXTENSIONS--
4+
imap
35
--SKIPIF--
46
<?php
57
if (PHP_OS_FAMILY !== 'Windows') die('skip Windows only test');

ext/standard/tests/mail/bug80751.phpt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Bug #80751 (Comma in recipient name breaks email delivery)
3+
--EXTENSIONS--
4+
imap
35
--SKIPIF--
46
<?php
57
if (PHP_OS_FAMILY !== 'Windows') die('skip Windows only test');
@@ -14,7 +16,7 @@ smtp_port=25
1416
require_once __DIR__ . '/mail_include.inc';
1517

1618
function find_and_delete_message($username, $subject) {
17-
global $default_mailbox, $password;
19+
global $default_mailbox, $password, $users, $domain;
1820

1921
$imap_stream = imap_open($default_mailbox, $username, $password);
2022
if ($imap_stream === false) {
@@ -35,11 +37,11 @@ function find_and_delete_message($username, $subject) {
3537
echo "Return-Path header found: ";
3638
var_dump(strpos($header, 'Return-Path: joe@example.com') !== false);
3739
echo "To header found: ";
38-
var_dump(strpos($header, 'To: "<bob@example.com>" <info@mail.local>') !== false);
40+
var_dump(strpos($header, "To: \"<bob@example.com>\" <{$users[1]}@$domain>") !== false);
3941
echo "From header found: ";
4042
var_dump(strpos($header, 'From: "<bob@example.com>" <joe@example.com>') !== false);
4143
echo "Cc header found: ";
42-
var_dump(strpos($header, 'Cc: "Lastname, Firstname\\\\" <admin@mail.local>') !== false);
44+
var_dump(strpos($header, "Cc: \"Lastname, Firstname\\\\\" <{$users[2]}@$domain>") !== false);
4345
imap_delete($imap_stream, $i);
4446
$found = true;
4547
break;

ext/standard/tests/mail/mail_basic_alt1-win32.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Test mail() function : basic functionality
3+
--EXTENSIONS--
4+
imap
35
--SKIPIF--
46
<?php
57

ext/standard/tests/mail/mail_basic_alt2-win32.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Test mail() function : basic functionality
3+
--EXTENSIONS--
4+
imap
35
--SKIPIF--
46
<?php
57
if( substr(PHP_OS, 0, 3) != 'WIN' ) {

ext/standard/tests/mail/mail_basic_alt3-win32.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Test mail() function : basic functionality
3+
--EXTENSIONS--
4+
imap
35
--SKIPIF--
46
<?php
57
if( substr(PHP_OS, 0, 3) != 'WIN' ) {

ext/standard/tests/mail/mail_basic_alt4-win32.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Test mail() function : basic functionality
3+
--EXTENSIONS--
4+
imap
35
--SKIPIF--
46
<?php
57
if( substr(PHP_OS, 0, 3) != 'WIN' ) {

ext/standard/tests/mail/mail_include.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
// Change these to make tests run successfully
3-
$server = '{localhost}';
3+
$server = '{127.0.0.1:143}';
44
$default_mailbox = $server . "INBOX";
55
$domain = "example.com";
66
$admin_user = "webmaster"; // a user with admin access

ext/standard/tests/mail/mail_skipif.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
extension_loaded('imap') or die('skip imap extension not available in this build');
32

43
if( substr(PHP_OS, 0, 3) == 'WIN' && extension_loaded('sockets')) {
54
// be sure mail server is accessible... on PHP 5.3.13 release build, using test-pack PHP-5.3-r1af8b3f,
@@ -12,7 +11,7 @@ if( substr(PHP_OS, 0, 3) == 'WIN' && extension_loaded('sockets')) {
1211
}
1312

1413
// Change these to make tests run successfully
15-
$mailbox = '{localhost}';
14+
$mailbox = '{127.0.0.1:143}';
1615
$username = 'webmaster@example.com';
1716
$password = 'p4ssw0rd';
1817
$options = OP_HALFOPEN; // this should be enough to verify server present

ext/standard/tests/mail/mail_variation_alt1-win32.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Test mail() function : basic functionality
3+
--EXTENSIONS--
4+
imap
35
--SKIPIF--
46
<?php
57
if( substr(PHP_OS, 0, 3) != 'WIN' ) {

ext/standard/tests/mail/mail_variation_alt2-win32.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Test mail() function : basic functionality
3+
--EXTENSIONS--
4+
imap
35
--SKIPIF--
46
<?php
57
if( substr(PHP_OS, 0, 3) != 'WIN' ) {

ext/standard/tests/mail/mail_variation_alt3-win32.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Test mail() function : basic functionality
3+
--EXTENSIONS--
4+
imap
35
--SKIPIF--
46
<?php
57
if( substr(PHP_OS, 0, 3) != 'WIN' ) {

0 commit comments

Comments
 (0)