-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from openeuropa/EWPP-772
EWPP-772: Remove HTML markup in the contact form emails.
- Loading branch information
Showing
2 changed files
with
84 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,10 +186,7 @@ public function testCorporateForm(): void { | |
$this->assertTrue($captured_emails[0]['to'] === $topics['0']['topic_email_address']); | ||
// Make sure we have an autoreply. | ||
$this->assertTrue($captured_emails[1]['id'] === 'contact_page_autoreply'); | ||
// Assert fields in autoreply. | ||
$this->assertTrue(strpos($captured_emails[1]['body'], 'Test subject') !== FALSE); | ||
$this->assertTrue(strpos($captured_emails[1]['body'], 'Test message') !== FALSE); | ||
$this->assertTrue(strpos($captured_emails[1]['body'], $topics['0']['topic_name']) !== FALSE); | ||
$this->assertTestEmailBodies($captured_emails); | ||
|
||
// Assert that instead of the user being redirected to the homepage, | ||
// they are redirected to the same, contact form page. | ||
|
@@ -280,4 +277,80 @@ public function testDefaultFormNotChanged(): void { | |
$this->assertUrl('/'); | ||
} | ||
|
||
/** | ||
* Asserts the sent emails are correctly formatted. | ||
* | ||
* @param array $captured_emails | ||
* The captured emails that were sent out: main one and auto-reply. | ||
* | ||
* @see self::testCorporateForm | ||
*/ | ||
protected function assertTestEmailBodies(array $captured_emails): void { | ||
// First email is the outgoing one. | ||
$expected = <<<EOF | ||
tester (not verified) ([email protected]) sent a message using the contact | ||
form at http://web:8080/build/contact/oe_contact_form. | ||
The sender's name | ||
tester | ||
The sender's email | ||
[email protected] | ||
Subject | ||
Test subject | ||
Message | ||
Test message | ||
Topic | ||
Changed name | ||
EOF; | ||
|
||
$this->assertEquals(preg_replace('/\s+/', ' ', $expected), preg_replace('/\s+/', ' ', $captured_emails[0]['body'])); | ||
|
||
// The second is the autoreply. | ||
$expected = <<<EOF | ||
this is a autoreply | ||
The sender's name | ||
tester | ||
The sender's email | ||
[email protected] | ||
Subject | ||
Test subject | ||
Message | ||
Test message | ||
Topic | ||
Changed name | ||
EOF; | ||
|
||
$this->assertEquals(preg_replace('/\s+/', ' ', $expected), preg_replace('/\s+/', ' ', $captured_emails[1]['body'])); | ||
} | ||
|
||
} |