Skip to content

Commit 5aaffc8

Browse files
committed
Backport IMAP test modernization to PHP-8.0 branch
Closes GH-6476
1 parent 83cf4aa commit 5aaffc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+493
-477
lines changed

azure/setup.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ steps:
2020
set -e
2121
sudo groupadd -g 5000 vmail
2222
sudo useradd -m -d /var/vmail -s /bin/false -u 5000 -g vmail vmail
23-
sudo cp ext/imap/tests/dovecot.conf /etc/dovecot/dovecot.conf
24-
sudo cp ext/imap/tests/dovecotpass /etc/dovecot/dovecotpass
23+
sudo cp ext/imap/tests/setup/dovecot.conf /etc/dovecot/dovecot.conf
24+
sudo cp ext/imap/tests/setup/dovecotpass /etc/dovecot/dovecotpass
2525
sudo service dovecot restart
2626
displayName: 'Configure IMAP'
2727

ext/imap/tests/CONFLICTS

Lines changed: 0 additions & 1 deletion
This file was deleted.

ext/imap/tests/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ hMailServer on Windows. The tests are intended to be mailserver agnostic.
1111

1212
## Set-up tests on Ubuntu (checked on Ubuntu 18.04 (Bionic))
1313
The necessary packages can be installed using the following command;
14-
`apt-get install libc-client-dev libkrb5-dev dovecot-core dovecot-pop3d dovecot-imapd`
14+
`apt-get install libc-client-dev libkrb5-dev dovecot-core dovecot-pop3d dovecot-imapd sendmail`
1515

1616
The build of PHP will need to be compiled with the following flags:
1717
```
1818
--with-imap --with-kerberos --with-imap-ssl
1919
```
2020

21-
Then run the set-up script `ext/imap/tests/setup.sh` which will add the `vmail`
21+
Then run the set-up script `ext/imap/tests/setup/setup.sh` which will add the `vmail`
2222
group and user which is used by Dovecot for the mailbox. It will also copy the
23-
`ext/imap/tests/dovecot.conf` and `ext/imap/tests/dovecotpass` to the correct
23+
`ext/imap/tests/setup/dovecot.conf` and `ext/imap/tests/setup/dovecotpass` to the correct
2424
location for Dovecot and restarts it for the new configuration to be enabled.

ext/imap/tests/bug31142_2.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
Bug #31142 test #2 (imap_mail_compose() generates incorrect output)
33
--SKIPIF--
44
<?php
5-
if (!extension_loaded("imap")) {
6-
die("skip imap extension not available");
7-
}
5+
extension_loaded('imap') or die('skip imap extension not available in this build');
86
?>
97
--FILE--
108
<?php

ext/imap/tests/bug32589.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
Bug #32589 (crash inside imap_mail_compose() function)
33
--SKIPIF--
44
<?php
5-
if (!extension_loaded("imap")) {
6-
die("skip imap extension not available");
7-
}
5+
extension_loaded('imap') or die('skip imap extension not available in this build');
86
?>
97
--FILE--
108
<?php

ext/imap/tests/bug35669.phpt

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,43 @@
22
Bug #35669 (imap_mail_compose() crashes with multipart-multiboundary-email)
33
--SKIPIF--
44
<?php
5-
if (!extension_loaded("imap")) {
6-
die("skip imap extension not available");
7-
}
5+
extension_loaded('imap') or die('skip imap extension not available in this build');
86
?>
97
--FILE--
108
<?php
11-
$envelope["from"] = 'Santa <somewhere@northpole.gov>';
12-
$envelope["to"] = 'The bad smurf <bad@smurf.com>';
13-
$envelope['date'] = 'Wed, 04 Jan 2006 19:24:43 -0500';
9+
$envelope["from"] = 'Santa <somewhere@northpole.gov>';
10+
$envelope["to"] = 'The bad smurf <bad@smurf.com>';
11+
$envelope['date'] = 'Wed, 04 Jan 2006 19:24:43 -0500';
1412

15-
$multipart["type"] = TYPEMULTIPART;
16-
$multipart["subtype"] = "MIXED";
17-
$body[] = $multipart; //add multipart stuff
13+
$multipart["type"] = TYPEMULTIPART;
14+
$multipart["subtype"] = "MIXED";
15+
$body[] = $multipart; //add multipart stuff
1816

19-
$textpart["type"] = TYPEMULTIPART;
20-
$textpart["subtype"] = "ALTERNATIVE";
21-
$body[] = $textpart; //add body part
17+
$textpart["type"] = TYPEMULTIPART;
18+
$textpart["subtype"] = "ALTERNATIVE";
19+
$body[] = $textpart; //add body part
2220

23-
$plain["type"] = TYPETEXT;
24-
$plain["subtype"] = "PLAIN";
25-
$plain["charset"] = "iso-8859-1";
26-
$plain["encoding"] = ENCQUOTEDPRINTABLE;
27-
$plain["description"] = "Plaintype part of message";
28-
$plain['disposition'] = "inline";
29-
$plain["contents.data"] = 'See mom, it will crash';
21+
$plain["type"] = TYPETEXT;
22+
$plain["subtype"] = "PLAIN";
23+
$plain["charset"] = "iso-8859-1";
24+
$plain["encoding"] = ENCQUOTEDPRINTABLE;
25+
$plain["description"] = "Plaintype part of message";
26+
$plain['disposition'] = "inline";
27+
$plain["contents.data"] = 'See mom, it will crash';
3028

31-
$body[] = $plain; //next add plain text part
29+
$body[] = $plain; //next add plain text part
3230

33-
$html["type"] = TYPETEXT;
34-
$html["subtype"] = "HTML";
35-
$html["charset"] = "iso-8859-1";
36-
$html["encoding"] = ENCQUOTEDPRINTABLE;
37-
$html["description"] = "HTML part of message";
38-
$html['disposition'] = "inline";
39-
$html["contents.data"] = 'See mom, it will <b>crash</b>';
31+
$html["type"] = TYPETEXT;
32+
$html["subtype"] = "HTML";
33+
$html["charset"] = "iso-8859-1";
34+
$html["encoding"] = ENCQUOTEDPRINTABLE;
35+
$html["description"] = "HTML part of message";
36+
$html['disposition'] = "inline";
37+
$html["contents.data"] = 'See mom, it will <b>crash</b>';
4038

41-
$body[] = $html;
39+
$body[] = $html;
4240

43-
echo imap_mail_compose($envelope, $body);
41+
echo imap_mail_compose($envelope, $body);
4442
?>
4543
--EXPECTF--
4644
Date: Wed, 04 Jan 2006 19:24:43 -0500

ext/imap/tests/bug44098.phpt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
Bug #44098 (imap_utf8() returns only capital letters)
33
--SKIPIF--
44
<?php
5-
if (!extension_loaded("imap")) {
6-
die("skip imap extension not available");
7-
}
5+
extension_loaded('imap') or die('skip imap extension not available in this build');
86
?>
97
--FILE--
108
<?php
119
$exp = 'Luzon®14 dot CoM';
1210
$res = imap_utf8('=?iso-8859-1?b?THV6b26uMTQ=?= dot CoM');
13-
if ($res != $exp) {
14-
echo "failed: got <$res>, expected <exp>\n";
15-
} else {
16-
echo "ok";
17-
}
11+
var_dump($res);
12+
1813
?>
1914
--EXPECT--
20-
ok
15+
string(17) "Luzon®14 dot CoM"

ext/imap/tests/bug45705_1.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
Bug #45705 test #1 (imap rfc822_parse_adrlist() modifies passed address parameter)
33
--SKIPIF--
44
<?php
5-
if (!extension_loaded("imap")) {
6-
die("skip imap extension not available");
7-
}
5+
extension_loaded('imap') or die('skip imap extension not available in this build');
86
?>
97
--FILE--
108
<?php

ext/imap/tests/bug45705_2.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
Bug #45705 test #2 (imap rfc822_parse_adrlist() modifies passed address parameter)
33
--SKIPIF--
44
<?php
5-
if (!extension_loaded("imap")) {
6-
die("skip imap extension not available");
7-
}
5+
extension_loaded('imap') or die('skip imap extension not available in this build');
86
?>
97
--FILE--
108
<?php

ext/imap/tests/bug53377.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
Bug #53377 (imap_mime_header_decode() doesn't ignore \t during long MIME header unfolding)
33
--SKIPIF--
44
<?php
5-
if (!extension_loaded("imap")) {
6-
die("skip imap extension not available");
7-
}
5+
extension_loaded('imap') or die('skip imap extension not available in this build');
86
?>
97
--FILE--
108
<?php

ext/imap/tests/bug63126.phpt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ imap_open() DISABLE_AUTHENTICATOR ignores array param
44
<?php
55
extension_loaded('imap') or die('skip imap extension not available in this build');
66

7-
require_once(__DIR__.'/imap_include.inc');
7+
require_once(__DIR__. '/setup/imap_include.inc');
88

9-
$in = @imap_open($default_mailbox, $username, $password, OP_HALFOPEN, 1);
9+
$in = @imap_open(IMAP_SERVER_DEBUG, IMAP_MAILBOX_USERNAME, IMAP_MAILBOX_PASSWORD, OP_HALFOPEN, 1);
1010
if (!$in) {
11-
die("skip could not connect to mailbox $default_mailbox");
11+
die("skip could not connect to mailbox " . IMAP_SERVER_DEBUG);
1212
}
1313
$kerberos = false;
1414
if (is_array($errors = imap_errors())) {
@@ -22,16 +22,19 @@ if (!$kerberos) {
2222
die("skip need a GSSAPI/Kerberos aware server");
2323
}
2424
?>
25+
--CONFLICTS--
26+
defaultmailbox
2527
--FILE--
2628
<?php
29+
// TODO Test Kerberos on CI
2730
$tests = array(
2831
'Array' => array('DISABLE_AUTHENTICATOR' => array('GSSAPI','NTLM')),
2932
'String' => array('DISABLE_AUTHENTICATOR' => 'GSSAPI'),
3033
);
31-
require_once(__DIR__.'/imap_include.inc');
34+
require_once(__DIR__. '/setup/imap_include.inc');
3235
foreach ($tests as $name => $testparams) {
3336
echo "Test for $name\n";
34-
$in = imap_open($default_mailbox, $username, $password, OP_HALFOPEN, 1, $testparams);
37+
$in = imap_open(IMAP_SERVER_DEBUG, IMAP_MAILBOX_USERNAME, IMAP_MAILBOX_PASSWORD, OP_HALFOPEN, 1, $testparams);
3538
if ($in) {
3639
if (is_array($errors = imap_errors())) {
3740
foreach ($errors as $err) {

ext/imap/tests/bug64076.phpt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22
Bug #64076 (imap_sort() does not return FALSE on failure)
33
--SKIPIF--
44
<?php
5-
require_once __DIR__ . '/skipif.inc';
5+
require_once __DIR__ . '/setup/skipif.inc';
66
?>
77
--FILE--
88
<?php
9-
require_once __DIR__ . '/imap_include.inc';
10-
$stream = setup_test_mailbox('', 2);
9+
require_once __DIR__ . '/setup/imap_include.inc';
10+
$stream = setup_test_mailbox('bug64076', 2);
1111
imap_errors(); // clear error stack
1212
var_dump(imap_sort($stream, SORTFROM, 0, 0, 'UNSUPPORTED SEARCH CRITERIUM'));
1313
var_dump(imap_errors() !== false);
1414
?>
1515
--CLEAN--
1616
<?php
17-
require_once __DIR__ . '/clean.inc';
17+
$mailbox_suffix = 'bug64076';
18+
require_once(__DIR__ . '/setup/clean.inc');
1819
?>
1920
--EXPECT--
2021
Create a temporary mailbox and add 2 msgs
21-
.. mailbox '{127.0.0.1:143/norsh}INBOX.phpttest' created
22+
New mailbox created
2223
bool(false)
2324
bool(true)

ext/imap/tests/bug77020.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ if (!extension_loaded('imap')) die('skip imap extension not available');
66
?>
77
--FILE--
88
<?php
9-
imap_mail('1', 1, NULL);
9+
@imap_mail('1', 1, NULL);
10+
echo 'done'
1011
?>
1112
--EXPECTF--
12-
Warning: imap_mail(): No message string in mail command in %s on line %d
13-
%S
13+
%Adone

ext/imap/tests/bug77153.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
--TEST--
1+
--TEST--
22
Bug #77153 (imap_open allows to run arbitrary shell commands via mailbox parameter)
33
--SKIPIF--
44
<?php
5-
if (!extension_loaded("imap")) {
6-
die("skip imap extension not available");
7-
}
5+
extension_loaded('imap') or die('skip imap extension not available in this build');
86
?>
7+
--CONFLICTS--
8+
defaultmailbox
99
--FILE--
1010
<?php
1111
$payload = "echo 'BUG'> " . __DIR__ . '/__bug';
@@ -21,4 +21,4 @@ bool(false)
2121
--CLEAN--
2222
<?php
2323
if(file_exists(__DIR__ . '/__bug')) unlink(__DIR__ . '/__bug');
24-
?>
24+
?>

ext/imap/tests/bug80213.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ $body = [[
1414
'type.parameters' => ['param'],
1515
'disposition' => ['disp'],
1616
]];
17-
imap_mail_compose($envelope, $body);
17+
var_dump(imap_mail_compose($envelope, $body));
1818
echo "done\n";
1919
?>
2020
--EXPECT--
21+
string(67) "MIME-Version: 1.0
22+
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
23+
24+
25+
"
2126
done

ext/imap/tests/bug80226.phpt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,25 @@
22
Bug #80226 (imap_sort() leaks sortpgm memory)
33
--SKIPIF--
44
<?php
5-
require_once(__DIR__.'/skipif.inc');
5+
require_once(__DIR__.'/setup/skipif.inc');
66
?>
77
--FILE--
88
<?php
9-
require_once(__DIR__.'/imap_include.inc');
10-
$stream = imap_open($default_mailbox, $username, $password);
11-
imap_sort($stream, SORTFROM, 0);
9+
require_once(__DIR__.'/setup/imap_include.inc');
10+
11+
echo "Create a new mailbox for test\n";
12+
13+
$stream = setup_test_mailbox("bug80226", 0);
14+
var_dump(imap_sort($stream, SORTFROM, 0));
15+
?>
16+
--CLEAN--
17+
<?php
18+
$mailbox_suffix = 'bug80226';
19+
require_once(__DIR__ . '/setup/clean.inc');
1220
?>
1321
--EXPECT--
22+
Create a new mailbox for test
23+
Create a temporary mailbox and add 0 msgs
24+
New mailbox created
25+
array(0) {
26+
}

ext/imap/tests/bug80438.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
Bug #80438: imap_msgno() incorrectly warns and return false on valid UIDs in PHP 8.0.0
33
--SKIPIF--
44
<?php
5-
require_once(__DIR__.'/skipif.inc');
5+
require_once(__DIR__.'/setup/skipif.inc');
66
?>
77
--FILE--
88
<?php
9-
echo "*** Testing imap_fetch_overview() : basic functionality ***\n";
109

1110
require_once __DIR__.'/setup/imap_include.inc';
1211

@@ -41,7 +40,6 @@ $mailbox_suffix = 'bug80438';
4140
require_once __DIR__.'/setup/clean.inc';
4241
?>
4342
--EXPECT--
44-
*** Testing imap_fetch_overview() : basic functionality ***
4543
Create a temporary mailbox and add 10 msgs
4644
New mailbox created
4745
array(6) {

ext/imap/tests/clean.inc

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)