ContactEmailsRecipientReferenceTest.php in Contact Emails 8
File
src/Tests/ContactEmailsRecipientReferenceTest.php
View source
<?php
namespace Drupal\contact_emails\Tests;
use Drupal\contact_emails\ContactEmailsTestBase;
class ContactEmailsRecipientReferenceTest extends ContactEmailsTestBase {
public static $modules = [
'contact',
'contact_storage',
'contact_emails',
'contact_emails_test_mail_alter',
'field_ui',
'entity_reference',
];
public function testSendToReferencedField() {
$this
->addContactFormWithEmailFieldForReferencing();
$params = [
'subject[0][value]' => 'Contact Emails Test Form Subject',
'message[0][value]' => 'Contact Emails Test Form Body',
'recipient_type[0][value]' => 'reference',
'recipient_reference[0][value]' => 'field_reference.contact_message.contact_reference_test_form.field_email_reference',
'reply_to_type[0][value]' => 'default',
'status[value]' => TRUE,
];
$this
->drupalPostForm('/admin/structure/contact/manage/contact_emails_test_form/emails/add', $params, t('Save'));
$this
->drupalGet('/contact/contact_emails_test_form');
$elements = $this
->xpath('//select[@name="field_reference"]');
$options = $elements[0]
->findAll('xpath', '//option');
$last_option = end($options);
$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'));
$this
->assertText('Message-to:email-via-reference@test.com', 'Message to set successfully.');
}
}