From 1e05f033a163935525f67f7986e546a64dc04eda Mon Sep 17 00:00:00 2001 From: andrew farquharson <farquharson.a@gmail.com> Date: Thu, 19 Dec 2024 04:18:24 +0000 Subject: [PATCH] use same test function etc in FunctionalJavascript test --- .../UserPasswordResetTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/modules/user/tests/src/FunctionalJavascript/UserPasswordResetTest.php b/core/modules/user/tests/src/FunctionalJavascript/UserPasswordResetTest.php index 5d996c0298ed..061f8cf40114 100644 --- a/core/modules/user/tests/src/FunctionalJavascript/UserPasswordResetTest.php +++ b/core/modules/user/tests/src/FunctionalJavascript/UserPasswordResetTest.php @@ -84,6 +84,9 @@ public function testUserPasswordResetWithAdditionalAjaxForm(): void { $edit['name'] = $this->account->getAccountName(); $this->submitForm($edit, 'Submit'); + // Check that the email message body does not contain HTML entities + $this->assertTrue($this->checkBodyText(), 'The body text of the email contains no HTML entities'); + $resetURL = $this->getResetURL(); $this->drupalGet($resetURL); @@ -122,4 +125,17 @@ public function getResetURL() { return $urls[0]; } + /** + * Checks the email body text for the presence of HTML entities. + */ + public function checkBodyText(): bool { + // Assume the most recent email. + $_emails = $this->drupalGetMails(); + $email = end($_emails); + if (strip_tags($email['body']) === $email['body']) { + return TRUE; + } + return FALSE; + } + } -- GitLab