Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automatic_updates-3449631
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
automatic_updates-3449631
Commits
d9220bf4
Commit
d9220bf4
authored
1 year ago
by
Ted Bowman
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3380698
: Make EmailNotificationsTestTrait::assertMessagesSent() clearer...
Issue
#3380698
: Make EmailNotificationsTestTrait::assertMessagesSent() clearer by renaming variables
parent
4ef42b95
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/Traits/EmailNotificationsTestTrait.php
+15
-15
15 additions, 15 deletions
tests/src/Traits/EmailNotificationsTestTrait.php
with
15 additions
and
15 deletions
tests/src/Traits/EmailNotificationsTestTrait.php
+
15
−
15
View file @
d9220bf4
...
@@ -56,40 +56,40 @@ trait EmailNotificationsTestTrait {
...
@@ -56,40 +56,40 @@ trait EmailNotificationsTestTrait {
/**
/**
* Asserts that all recipients received a given email.
* Asserts that all recipients received a given email.
*
*
* @param string $subject
* @param string $
expected_
subject
* The subject line of the email that should have been sent.
* The subject line of the email that should have been sent.
* @param string $body
* @param string $
expected_
body
* The beginning of the body text of the email that should have been sent.
* The beginning of the body text of the email that should have been sent.
*
*
* @see ::$emailRecipients
* @see ::$emailRecipients
*/
*/
protected
function
assertMessagesSent
(
string
$subject
,
string
$body
):
void
{
protected
function
assertMessagesSent
(
string
$
expected_
subject
,
string
$
expected_
body
):
void
{
$sent_messages
=
$this
->
getMails
([
$sent_messages
=
$this
->
getMails
([
'subject'
=>
$subject
,
'subject'
=>
$
expected_
subject
,
]);
]);
$this
->
assertNotEmpty
(
$sent_messages
);
$this
->
assertNotEmpty
(
$sent_messages
);
$this
->
assertCount
(
count
(
$this
->
emailRecipients
),
$sent_messages
);
$this
->
assertCount
(
count
(
$this
->
emailRecipients
),
$sent_messages
);
// Ensure the body is formatted the way the PHP mailer would do it.
// Ensure the body is formatted the way the PHP mailer would do it.
$message
=
[
$
expected_
message
=
[
'body'
=>
[
$body
],
'body'
=>
[
$
expected_
body
],
];
];
$message
=
$this
->
container
->
get
(
'plugin.manager.mail'
)
$
expected_
message
=
$this
->
container
->
get
(
'plugin.manager.mail'
)
->
createInstance
(
'php_mail'
)
->
createInstance
(
'php_mail'
)
->
format
(
$message
);
->
format
(
$
expected_
message
);
$
body
=
$
message
[
'body'
];
$
expected_body
=
$expected_
message
[
'body'
];
foreach
(
$sent_messages
as
$message
)
{
foreach
(
$sent_messages
as
$
sent_
message
)
{
$email
=
$message
[
'to'
];
$email
=
$
sent_
message
[
'to'
];
$expected_langcode
=
$this
->
emailRecipients
[
$email
];
$expected_langcode
=
$this
->
emailRecipients
[
$email
];
$this
->
assertSame
(
$expected_langcode
,
$message
[
'langcode'
]);
$this
->
assertSame
(
$expected_langcode
,
$
sent_
message
[
'langcode'
]);
// The message, and every line in it, should have been sent in the
// The message, and every line in it, should have been sent in the
// expected language.
// expected language.
// @see automatic_updates_test_mail_alter()
// @see automatic_updates_test_mail_alter()
$this
->
assertArrayHasKey
(
'line_langcodes'
,
$message
);
$this
->
assertArrayHasKey
(
'line_langcodes'
,
$
sent_
message
);
$this
->
assertSame
([
$expected_langcode
],
$message
[
'line_langcodes'
]);
$this
->
assertSame
([
$expected_langcode
],
$
sent_
message
[
'line_langcodes'
]);
$this
->
assertStringStartsWith
(
$body
,
$message
[
'body'
]);
$this
->
assertStringStartsWith
(
$
expected_
body
,
$
sent_
message
[
'body'
]);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment