Add AssertMailTrait to test token replacement in email

Created on 2 June 2025, 5 days ago

Problem/Motivation

Currently the test cases cover submitting the validation form, but not that the email generated contains the correct replacement. The AssertMailTrait trait allows testing of the email text to check this.

Steps to reproduce

See parent.

Proposed resolution

Update VerifyEmailRoutingTest to test the sent message.

Remaining tasks

In VerifyEmailRoutingTest.php add a use statement for Drupal\Core\Test\AssertMailTrait.
In the class add a use statement for the trait.
In the setUp function, add [verify-email:url] into the email_body of the VerifyEmail entity.
In the testVerifyEmailForm test function, add a call to $this->assertMailString, to test the message still contains "Please click on this link" (pass 1 into the email_depth parameter).
Add a second call to $this->assertMailString to check the token has been replaced. I'm not sure that we can easily get the exact URL to check against, but we know it will contain "/verify/", so testing for that is sufficient to test that the substitution has taken place.

User interface changes

None.

API changes

None.

Data model changes

None.

📌 Task
Status

Active

Version

1.1

Component

Code

Created by

🇮🇪Ireland lostcarpark

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024