You are here

public function ContactTest::setUp in Reroute Email 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/ContactTest.php \Drupal\Tests\reroute_email\Functional\ContactTest::setUp()

Enable modules and create user with specific permissions.

Overrides RerouteEmailTestBase::setUp

File

tests/src/Functional/ContactTest.php, line 23

Class

ContactTest
Test ability to reroute mail sent from the Contact module form.

Namespace

Drupal\Tests\reroute_email\Functional

Code

public function setUp() {

  // Add more permissions to be able to manipulate the contact forms.
  $this->permissions[] = 'administer contact forms';
  $this->permissions[] = 'access site-wide contact form';
  $this->confirmationMessage = 'Your message has been sent.';
  parent::setUp();

  // Create a "feedback" contact form. Note that the 'message' was added in
  // the 8.2.x series, and is not there in 8.1.x, so this could fail in 8.1.x.
  $this
    ->drupalPostForm('admin/structure/contact/add', [
    'label' => 'feedback',
    'id' => 'feedback',
    'recipients' => $this->originalDestination,
    'message' => $this->confirmationMessage,
    'selected' => TRUE,
  ], 'Save');
  $this
    ->assertResponse(200, 'Contact form named "feedback" added.');

  // Make sure that the flood controls don't break the test.
  \Drupal::service('config.factory')
    ->getEditable('contact.settings')
    ->set('flood.limit', 1000)
    ->set('flood.interval', 60);
}