public function ContactEmailsReplyToReferenceTest::testReplyToReferencedField in Contact Emails 8
Test referenced field functionality reply-to email address.
Throws
\Exception
File
- src/
Tests/ ContactEmailsReplyToReferenceTest.php, line 33
Class
- ContactEmailsReplyToReferenceTest
- Tests contact emails reply to and recipients.
Namespace
Drupal\contact_emails\TestsCode
public function testReplyToReferencedField() {
$this
->addContactFormWithEmailFieldForReferencing();
// Add the email.
$params = [
'subject[0][value]' => 'Contact Emails Test Form Subject',
'message[0][value]' => 'Contact Emails Test Form Body',
'recipient_type[0][value]' => 'default',
'reply_to_type[0][value]' => 'reference',
'reply_to_reference[0][value]' => 'field_reference.contact_message.contact_reference_test_form.field_email_reference',
'status[value]' => TRUE,
];
$this
->drupalPostForm('/admin/structure/contact/manage/contact_emails_test_form/emails/add', $params, t('Save'));
// Open the contact form on the front-end.
$this
->drupalGet('/contact/contact_emails_test_form');
// Get the reference options.
$elements = $this
->xpath('//select[@name="field_reference"]');
$options = $elements[0]
->findAll('xpath', '//option');
$last_option = end($options);
// Submit the contact form on the front-end of the website.
$params = [
'subject[0][value]' => 'Submission Test Form Subject',
'message[0][value]' => 'Submission Test Form Body',
'field_reference' => $last_option
->getValue(),
];
$this
->drupalPostForm(NULL, $params, t('Send message'));
// Assert that the message to is the email of the currently logged in user.
$this
->assertText('Message-reply-to:email-via-reference@test.com', 'Message reply-to set successfully.');
}