forked from silverstripe/silverstripe-userforms
-
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 silverstripe#881 from creative-commoners/pulls/5.4…
…/resilient-recipients Add presence validation for EmailRecipient recipient, add error handling
- Loading branch information
Showing
4 changed files
with
44 additions
and
7 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
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 |
---|---|---|
|
@@ -27,4 +27,15 @@ public function testShortcodesAreRenderedInEmailPreviewContent() | |
$result = $recipient->getEmailBodyContent(); | ||
$this->assertContains('/about-us/', $result); | ||
} | ||
|
||
/** | ||
* @expectedException SilverStripe\ORM\ValidationException | ||
* @expectedExceptionMessage "Send email to" address or field is required | ||
*/ | ||
public function testEmptyRecipientFailsValidation() | ||
{ | ||
$recipient = new EmailRecipient(); | ||
$recipient->EmailFrom = '[email protected]'; | ||
$recipient->write(); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -104,7 +104,6 @@ public function testGetCMSFieldsShowInSummary() | |
$this->assertNotContains('SummaryHide', array_keys($summaryFields), 'Summary field showing displayed field'); | ||
} | ||
|
||
|
||
public function testEmailRecipientPopup() | ||
{ | ||
$this->logInWithPermission('ADMIN'); | ||
|
@@ -114,6 +113,7 @@ public function testEmailRecipientPopup() | |
$popup = new EmailRecipient(); | ||
$popup->FormID = $form->ID; | ||
$popup->FormClass = UserDefinedForm::class; | ||
$popup->EmailAddress = '[email protected]'; | ||
|
||
$fields = $popup->getCMSFields(); | ||
|
||
|
@@ -146,6 +146,7 @@ public function testEmailRecipientPopup() | |
public function testGetEmailBodyContent() | ||
{ | ||
$recipient = new EmailRecipient(); | ||
$recipient->EmailAddress = '[email protected]'; | ||
|
||
$emailBody = 'not html'; | ||
$emailBodyHtml = '<p>html</p>'; | ||
|
@@ -185,6 +186,7 @@ public function testEmailTemplateExists() | |
$recipient = new EmailRecipient(); | ||
$recipient->FormID = $page->ID; | ||
$recipient->FormClass = UserDefinedForm::class; | ||
$recipient->EmailAddress = '[email protected]'; | ||
|
||
// Set the default template | ||
$recipient->EmailTemplate = current(array_keys($recipient->getEmailTemplateDropdownValues())); | ||
|