Skip to content

Commit d722de1

Browse files
committed
Address review comments
1 parent c437369 commit d722de1

File tree

6 files changed

+68
-61
lines changed

6 files changed

+68
-61
lines changed

ext/standard/tests/mail/bug72964.phpt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,40 @@ $res = mail($to, $subject, $message, $headers);
2828

2929
if ($res !== true) {
3030
exit("Unable to send the email.\n");
31-
} else {
32-
echo "Sent the email.\n";
3331
}
3432

33+
echo "Email sent.\n";
34+
3535
$res = searchEmailByToAddress($to);
3636

3737
if (mailCheckResponse($res, $from, $to, $subject, $message)) {
38-
echo "Received the email.\n";
38+
echo "Found the email sent.\n";
3939

4040
$ccAddresses = getCcAddresses($res);
4141
if (in_array($cc[0], $ccAddresses, true)) {
42-
echo "cc1 Received the email.\n";
42+
echo "cc1 is set.\n";
4343
}
4444

4545
if (in_array($cc[1], $ccAddresses, true)) {
46-
echo "cc2 Received the email.\n";
46+
echo "cc2 is set.\n";
4747
}
4848

4949
$bccAddresses = getBccAddresses($res);
5050
if (in_array($bcc[0], $bccAddresses, true)) {
51-
echo "bcc1 Received the email.\n";
51+
echo "bcc1 is set.\n";
5252
}
5353

5454
if (in_array($bcc[1], $bccAddresses, true)) {
55-
echo "bcc2 Received the email.";
55+
echo "bcc2 is set.";
5656
}
57-
58-
deleteEmail($res);
5957
}
6058
?>
59+
--CLEAN--
60+
<?php deleteEmailByToAddress('bug72964_to@example.com'); ?>
6161
--EXPECT--
62-
Sent the email.
63-
Received the email.
64-
cc1 Received the email.
65-
cc2 Received the email.
66-
bcc1 Received the email.
67-
bcc2 Received the email.
62+
Email sent.
63+
Found the email sent.
64+
cc1 is set.
65+
cc2 is set.
66+
bcc1 is set.
67+
bcc2 is set.

ext/standard/tests/mail/bug80706.phpt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,30 @@ $res = mail($to, $subject, $message, $headers);
2828

2929
if ($res !== true) {
3030
exit("Unable to send the email.\n");
31-
} else {
32-
echo "Sent the email.\n";
3331
}
3432

33+
echo "Email sent.\n";
34+
3535
$res = searchEmailByToAddress($to);
3636

3737
if (mailCheckResponse($res, $from, $to, $subject, $message)) {
38-
echo "Received the email.\n";
38+
echo "Found the email sent.\n";
3939

4040
$bccAddresses = getBccAddresses($res);
4141
if (in_array($bcc, $bccAddresses, true)) {
42-
echo "bcc Received the email.\n";
42+
echo "bcc is set.\n";
4343
}
4444

4545
$headers = getHeaders($res);
4646
if ($headers['X-Mailer'][0] === $xMailer) {
4747
echo "The specified x-Mailer exists.";
4848
}
49-
50-
deleteEmail($res);
5149
}
5250
?>
51+
--CLEAN--
52+
<?php deleteEmailByToAddress('bug80706_to@example.com'); ?>
5353
--EXPECT--
54-
Sent the email.
55-
Received the email.
56-
bcc Received the email.
54+
Email sent.
55+
Found the email sent.
56+
bcc is set.
5757
The specified x-Mailer exists.

ext/standard/tests/mail/bug80751.phpt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ $res = mail($toLine, $subject, $message, $headers);
3434

3535
if ($res !== true) {
3636
exit("Unable to send the email.\n");
37-
} else {
38-
echo "Sent the email.\n";
3937
}
4038

39+
echo "Email sent.\n";
40+
4141
$res = searchEmailByToAddress($to);
4242

4343
if (mailCheckResponse($res, $from, $to, $subject, $message)) {
44-
echo "Received the email.\n";
44+
echo "Found the email sent.\n";
4545

4646
$ccAddresses = getCcAddresses($res);
4747
if (in_array($cc, $ccAddresses, true)) {
48-
echo "cc Received the email.\n";
48+
echo "cc is set.\n";
4949
}
5050

5151
$bccAddresses = getBccAddresses($res);
5252
if (in_array($bcc, $bccAddresses, true)) {
53-
echo "bcc Receive the email.\n";
53+
echo "bcc is set.\n";
5454
}
5555

5656
if ($res['ReturnPath'] === $from) {
@@ -69,15 +69,15 @@ if (mailCheckResponse($res, $from, $to, $subject, $message)) {
6969
if ($headers['Cc'][0] === $ccLine) {
7070
echo "Cc header is as expected.";
7171
}
72-
73-
deleteEmail($res);
7472
}
7573
?>
74+
--CLEAN--
75+
<?php deleteEmailByToAddress('bug80751_to@example.com'); ?>
7676
--EXPECT--
77-
Sent the email.
78-
Received the email.
79-
cc Received the email.
80-
bcc Receive the email.
77+
Email sent.
78+
Found the email sent.
79+
cc is set.
80+
bcc is set.
8181
Return-Path is as expected.
8282
To header is as expected.
8383
From header is as expected.

ext/standard/tests/mail/mail_basic_win.phpt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,31 +60,37 @@ HERE;
6060

6161
if ($res !== true) {
6262
exit("Unable to send the email.\n");
63-
} else {
64-
echo "Sent the email.\n";
6563
}
6664

65+
echo "Email sent.\n";
66+
6767
$res = searchEmailByToAddress($to);
6868

6969
if (mailCheckResponse($res, $from, $to, $subject, $message)) {
70-
echo "Received the email.\n\n";
71-
deleteEmail($res);
70+
echo "Found the email sent.\n\n";
7271
}
7372
}
7473
?>
74+
--CLEAN--
75+
<?php
76+
deleteEmailByToAddress('mail_basic_win_0@example.com');
77+
deleteEmailByToAddress('mail_basic_win_1@example.com');
78+
deleteEmailByToAddress('mail_basic_win_2@example.com');
79+
deleteEmailByToAddress('mail_basic_win_3@example.com');
80+
?>
7581
--EXPECT--
7682
========== Case 0 ==========
77-
Sent the email.
78-
Received the email.
83+
Email sent.
84+
Found the email sent.
7985

8086
========== Case 1 ==========
81-
Sent the email.
82-
Received the email.
87+
Email sent.
88+
Found the email sent.
8389

8490
========== Case 2 ==========
85-
Sent the email.
86-
Received the email.
91+
Email sent.
92+
Found the email sent.
8793

8894
========== Case 3 ==========
89-
Sent the email.
90-
Received the email.
95+
Email sent.
96+
Found the email sent.

ext/standard/tests/mail/mail_variation_win.phpt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,22 @@ HERE;
5454
$res = mail($to, $subject, $message);
5555

5656
if ($res === true) {
57-
echo "Sent the email.\n";
57+
echo "Email sent.\n";
5858
}
5959

6060
$res = searchEmailByToAddress($to);
6161

6262
if (mailCheckResponse($res, $from, $to, $subject, $message)) {
63-
echo "Received the email.\n\n";
64-
deleteEmail($res);
63+
echo "Found the email sent.\n\n";
6564
}
6665
}
6766
?>
67+
--CLEAN--
68+
<?php
69+
deleteEmailByToAddress('mail_variation_win_0@example.com');
70+
deleteEmailByToAddress('mail_variation_win_1@example.com');
71+
deleteEmailByToAddress('mail_variation_win_2@example.com');
72+
?>
6873
--EXPECTF--
6974
========== From is not set ==========
7075

ext/standard/tests/mail/mailpit_utils.inc

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,13 @@ function getBccAddresses($res): array
4040
return array_column($res['Bcc'], 'Address');
4141
}
4242

43-
function deleteEmail($res)
43+
function deleteEmailByToAddress(string $to)
4444
{
45-
$id = $res['ID'] ?? null;
46-
47-
if ($id) {
48-
$query = urlencode("message-id:{$id}");
49-
file_get_contents("http://localhost:8025/api/v1/search?query={$query}", false, stream_context_create([
50-
'http' => [
51-
'method' => 'DELETE',
52-
],
53-
]));
54-
}
45+
$query = urlencode("to:{$to}");
46+
file_get_contents("http://localhost:8025/api/v1/search?query={$query}", false, stream_context_create([
47+
'http' => [
48+
'method' => 'DELETE',
49+
],
50+
]));
5551
}
5652
?>

0 commit comments

Comments
 (0)