Skip to content
Snippets Groups Projects
Verified Commit df2e782a authored by Pierre Rudloff's avatar Pierre Rudloff
Browse files

Refactor tests

parent 3dd675e3
No related branches found
No related tags found
1 merge request!10611Keep user emails plain text
...@@ -179,7 +179,10 @@ public function testUserPasswordReset(): void { ...@@ -179,7 +179,10 @@ public function testUserPasswordReset(): void {
$edit = ['name' => $this->account->getEmail()]; $edit = ['name' => $this->account->getEmail()];
$this->submitForm($edit, 'Submit'); $this->submitForm($edit, 'Submit');
// Check that the email message body does not contain HTML entities // Check that the email message body does not contain HTML entities
$this->assertTrue($this->checkBodyText(), 'Email body contains HTML entities'); // Assume the most recent email.
$_emails = $this->drupalGetMails();
$email = end($_emails);
$this->assertEquals(htmlspecialchars_decode($email['body']), $email['body'], 'Email body contains HTML entities');
// Change site name to 'Drupal' // Change site name to 'Drupal'
$config->set('name', "Drupal")->save(); $config->set('name', "Drupal")->save();
$this->rebuildContainer(); $this->rebuildContainer();
...@@ -341,19 +344,6 @@ public function getResetURL() { ...@@ -341,19 +344,6 @@ public function getResetURL() {
return $urls[0]; 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 (htmlspecialchars_decode($email['body']) === $email['body']) {
return TRUE;
}
return FALSE;
}
/** /**
* Tests user password reset while logged in. * Tests user password reset while logged in.
*/ */
......
...@@ -85,7 +85,10 @@ public function testUserPasswordResetWithAdditionalAjaxForm(): void { ...@@ -85,7 +85,10 @@ public function testUserPasswordResetWithAdditionalAjaxForm(): void {
$this->submitForm($edit, 'Submit'); $this->submitForm($edit, 'Submit');
// Check that the email message body does not contain HTML entities // Check that the email message body does not contain HTML entities
$this->assertTrue($this->checkBodyText(), 'The body text of the email contains HTML entities'); // Assume the most recent email.
$_emails = $this->drupalGetMails();
$email = end($_emails);
$this->assertEquals(htmlspecialchars_decode($email['body']), $email['body'], 'The body text of the email contains HTML entities');
$resetURL = $this->getResetURL(); $resetURL = $this->getResetURL();
$this->drupalGet($resetURL); $this->drupalGet($resetURL);
...@@ -125,17 +128,4 @@ public function getResetURL() { ...@@ -125,17 +128,4 @@ public function getResetURL() {
return $urls[0]; 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 (htmlspecialchars_decode($email['body']) === $email['body']) {
return TRUE;
}
return FALSE;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment