mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\UserForms\Tests\Model\Recipient;
|
|
|
|
use SilverStripe\CMS\Model\SiteTree;
|
|
use SilverStripe\Dev\SapphireTest;
|
|
use SilverStripe\UserForms\Model\Recipient\EmailRecipient;
|
|
|
|
class EmailRecipientTest extends SapphireTest
|
|
{
|
|
protected static $fixture_file = 'EmailRecipientTest.yml';
|
|
|
|
public function testShortcodesAreRenderedInEmailPreviewContent()
|
|
{
|
|
$page = $this->objFromFixture(SiteTree::class, 'about_us');
|
|
|
|
$recipient = EmailRecipient::create();
|
|
$recipient->SendPlain = false;
|
|
$recipient->EmailBodyHtml = '<p>Some email content. About us: [sitetree_link,id=' . $page->ID . '].</p>';
|
|
|
|
$result = $recipient->getEmailBodyContent();
|
|
$this->assertContains('/about-us/', $result);
|
|
|
|
$recipient->SendPlain = true;
|
|
$recipient->EmailBody = 'Some email content. About us: [sitetree_link,id=' . $page->ID . '].';
|
|
|
|
$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 = 'test@example.com';
|
|
$recipient->write();
|
|
}
|
|
}
|