mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Test for EmailRecipient Subject with MergeField
This commit is contained in:
parent
a8e21b193f
commit
55ea24232b
@ -11,6 +11,7 @@ use SilverStripe\Forms\FormAction;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\UserForms\Control\UserDefinedFormController;
|
||||
use SilverStripe\UserForms\Model\EditableFormField\EditableTextField;
|
||||
use SilverStripe\UserForms\Model\Recipient\EmailRecipient;
|
||||
use SilverStripe\UserForms\Model\Submission\SubmittedFormField;
|
||||
use SilverStripe\UserForms\Model\UserDefinedForm;
|
||||
use SilverStripe\View\ArrayData;
|
||||
@ -51,10 +52,10 @@ class UserDefinedFormControllerTest extends FunctionalTest
|
||||
$response = $this->submitForm('UserForm_Form_' . $form->ID, null, [$field->Name => 'Basic Value']);
|
||||
|
||||
// should have a submitted form field now
|
||||
$submitted = DataObject::get(SubmittedFormField::class, "\"Name\" = 'basic-text-name'");
|
||||
$submitted = DataObject::get(SubmittedFormField::class, "\"Name\" = 'basic_text_name'");
|
||||
$this->assertListAllMatch(
|
||||
[
|
||||
'Name' => 'basic-text-name',
|
||||
'Name' => 'basic_text_name',
|
||||
'Value' => 'Basic Value',
|
||||
'Title' => 'Basic Text Field'
|
||||
],
|
||||
@ -332,4 +333,38 @@ class UserDefinedFormControllerTest extends FunctionalTest
|
||||
|
||||
$this->assertEquals((string) $action[0]['value'], "Submit", "Submit button has default text");
|
||||
}
|
||||
|
||||
|
||||
public function testRecipientSubjectMergeFields()
|
||||
{
|
||||
$form = $this->setupFormFrontend();
|
||||
|
||||
$recipient = $this->objFromFixture(EmailRecipient::class, 'recipient-1');
|
||||
$recipient->EmailSubject = 'Email Subject: $basic_text_name';
|
||||
$recipient->write();
|
||||
|
||||
$this->autoFollowRedirection = false;
|
||||
$this->clearEmails();
|
||||
|
||||
// load the form
|
||||
$this->get($form->URLSegment);
|
||||
|
||||
$field = $this->objFromFixture(EditableTextField::class, 'basic-text');
|
||||
|
||||
$response = $this->submitForm('UserForm_Form_' . $form->ID, null, [$field->Name => 'Basic Value']);
|
||||
|
||||
// should have a submitted form field now
|
||||
$submitted = DataObject::get(SubmittedFormField::class, "\"Name\" = 'basic_text_name'");
|
||||
$this->assertListAllMatch(
|
||||
[
|
||||
'Name' => 'basic_text_name',
|
||||
'Value' => 'Basic Value',
|
||||
'Title' => 'Basic Text Field'
|
||||
],
|
||||
$submitted
|
||||
);
|
||||
|
||||
// check emails
|
||||
$this->assertEmailSent('test@example.com', 'no-reply@example.com', 'Email Subject: Basic Value');
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
SilverStripe\UserForms\Model\EditableFormField\EditableTextField:
|
||||
basic-text:
|
||||
Name: basic-text-name
|
||||
Name: basic_text_name
|
||||
Title: Basic Text Field
|
||||
|
||||
basic-text-2:
|
||||
Name: basic-text-name
|
||||
Name: basic_text_name
|
||||
Title: Basic Text Field
|
||||
|
||||
required-text:
|
||||
|
@ -63,11 +63,11 @@ SilverStripe\UserForms\Model\EditableFormField\EditableOption:
|
||||
|
||||
SilverStripe\UserForms\Model\EditableFormField\EditableTextField:
|
||||
basic-text:
|
||||
Name: basic-text-name
|
||||
Name: basic_text_name
|
||||
Title: Basic Text Field
|
||||
|
||||
basic-text-2:
|
||||
Name: basic-text-name
|
||||
Name: basic_text_name
|
||||
Title: Basic Text Field
|
||||
|
||||
your-name-field:
|
||||
|
Loading…
Reference in New Issue
Block a user