FIX Tests for email templates and whether they exist or not

This commit is contained in:
Robbie Averill 2017-08-24 15:29:27 +12:00
parent 298441b50b
commit faf04bff43
2 changed files with 9 additions and 6 deletions

View File

@ -499,7 +499,7 @@ class EmailRecipient extends DataObject
{
$t = ($template ? $template : $this->EmailTemplate);
return in_array($t, $this->getEmailTemplateDropdownValues());
return array_key_exists($t, $this->getEmailTemplateDropdownValues());
}
/**
@ -543,10 +543,13 @@ class EmailRecipient extends DataObject
strlen(BASE_PATH) + 1
);
$defaultPrefix = 'userforms/templates/';
$defaultPrefixes = ['userforms/templates/', 'templates/'];
foreach ($defaultPrefixes as $defaultPrefix) {
// Remove default userforms folder if it's provided
if (substr($templatePath, 0, strlen($defaultPrefix)) === $defaultPrefix) {
$templatePath = substr($templatePath, strlen($defaultPrefix));
break;
}
}
$templates[$templatePath] = $template['filename'];
}

View File

@ -160,7 +160,7 @@ class UserDefinedFormTest extends FunctionalTest
{
$recipient = new EmailRecipient();
$defaultValues = ['SubmittedFormEmail' => 'SubmittedFormEmail'];
$defaultValues = ['email/SubmittedFormEmail' => 'SubmittedFormEmail'];
$this->assertEquals($recipient->getEmailTemplateDropdownValues(), $defaultValues);
}