mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
FIX Cast template values as array, include list in CMS fields for recipients
This commit is contained in:
parent
e82dc5f121
commit
262510a450
@ -369,7 +369,8 @@ class EmailRecipient extends DataObject
|
||||
$fields->insertBefore(
|
||||
DropdownField::create(
|
||||
'EmailTemplate',
|
||||
_t('SilverStripe\\UserForms\\Model\\UserDefinedForm.EMAILTEMPLATE', 'Email template')
|
||||
_t('SilverStripe\\UserForms\\Model\\UserDefinedForm.EMAILTEMPLATE', 'Email template'),
|
||||
$templates
|
||||
)->addExtraClass('toggle-html-only'),
|
||||
'EmailBodyHtml'
|
||||
);
|
||||
@ -527,7 +528,7 @@ class EmailRecipient extends DataObject
|
||||
{
|
||||
$t = ($template ? $template : $this->EmailTemplate);
|
||||
|
||||
return array_key_exists($t, $this->getEmailTemplateDropdownValues());
|
||||
return array_key_exists($t, (array) $this->getEmailTemplateDropdownValues());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,16 +158,22 @@ class UserDefinedFormTest extends FunctionalTest
|
||||
|
||||
public function testGetEmailTemplateDropdownValues()
|
||||
{
|
||||
$page = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
|
||||
$recipient = new EmailRecipient();
|
||||
$recipient->FormID = $page->ID;
|
||||
|
||||
$defaultValues = ['email/SubmittedFormEmail' => 'SubmittedFormEmail'];
|
||||
$result = $recipient->getEmailTemplateDropdownValues();
|
||||
|
||||
$this->assertEquals($recipient->getEmailTemplateDropdownValues(), $defaultValues);
|
||||
// Installation path can be as a project when testing in Travis, so check partial match
|
||||
$this->assertContains('templates/email/SubmittedFormEmail', key($result));
|
||||
$this->assertSame('SubmittedFormEmail', current($result));
|
||||
}
|
||||
|
||||
public function testEmailTemplateExists()
|
||||
{
|
||||
$page = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
|
||||
$recipient = new EmailRecipient();
|
||||
$recipient->FormID = $page->ID;
|
||||
|
||||
// Set the default template
|
||||
$recipient->EmailTemplate = current(array_keys($recipient->getEmailTemplateDropdownValues()));
|
||||
@ -192,10 +198,9 @@ class UserDefinedFormTest extends FunctionalTest
|
||||
$this->assertTrue($recipient->canDelete());
|
||||
}
|
||||
|
||||
$member = Member::currentUser();
|
||||
$member->logOut();
|
||||
|
||||
$this->logOut();
|
||||
$this->logInWithPermission('SITETREE_VIEW_ALL');
|
||||
|
||||
foreach ($form->EmailRecipients() as $recipient) {
|
||||
$this->assertFalse($recipient->canEdit());
|
||||
$this->assertFalse($recipient->canDelete());
|
||||
|
Loading…
Reference in New Issue
Block a user