WebformHandlerEmailMappingTest.php in Webform 8.5
File
tests/src/Functional/Handler/WebformHandlerEmailMappingTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Handler;
use Drupal\webform\Entity\Webform;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformHandlerEmailMappingTest extends WebformBrowserTestBase {
protected static $testWebforms = [
'test_handler_email_mapping',
];
public function testEmailMapping() {
$site_name = \Drupal::config('system.site')
->get('name');
$site_mail = \Drupal::config('system.site')
->get('mail');
$webform = Webform::load('test_handler_email_mapping');
$this
->postSubmission($webform);
$this
->assertText("Select empty sent to empty@example.com from {$site_name} [{$site_mail}].");
$this
->assertText("Select default sent to default@default.com from {$site_name} [{$site_mail}].");
$this
->assertText('Email not sent for Select yes option handler because a To, CC, or BCC email was not provided.');
$this
->assertText('Email not sent for Checkboxes handler because a To, CC, or BCC email was not provided.');
$this
->assertText('Email not sent for Radios other handler because a To, CC, or BCC email was not provided.');
$edit = [
'select' => 'Yes',
];
$this
->postSubmission($webform, $edit);
$this
->assertText("Select yes option sent to yes@example.com from {$site_name} [{$site_mail}].");
$this
->assertText("Select default sent to default@default.com from {$site_name} [{$site_mail}].");
$this
->assertNoText("'Select empty' sent to empty@example.com from {$site_name} [{$site_mail}].");
$edit = [
'checkboxes[Saturday]' => TRUE,
'checkboxes[Sunday]' => TRUE,
];
$this
->postSubmission($webform, $edit);
$this
->assertText("Checkboxes sent to saturday@example.com,sunday@example.com from {$site_name} [{$site_mail}].");
$this
->assertNoText('Email not sent for Checkboxes handler because a To, CC, or BCC email was not provided.');
$edit = [
'radios_other[radios]' => '_other_',
'radios_other[other]' => '{Other}',
];
$this
->postSubmission($webform, $edit);
$this
->assertText("Radios other sent to other@example.com from {$site_name} [{$site_mail}].");
$this
->assertNoText('Email not sent for Radios other handler because a To, CC, or BCC email was not provided.');
}
}