You are here

public function ContactStorageTestBase::addContactForm in Contact Storage 8

Adds a form.

Parameters

string $id: The form machine name.

string $label: The form label.

string $recipients: The list of recipient email addresses.

bool $selected: A Boolean indicating whether the form should be selected by default.

array $third_party_settings: Array of third party settings to be added to the posted form data.

string $message: The message that will be displayed to a user upon completing the contact form.

6 calls to ContactStorageTestBase::addContactForm()
BulkFormTest::setUp in tests/src/Functional/BulkFormTest.php
ContactStorageTest::testAutoReplyField in tests/src/Functional/ContactStorageTest.php
Tests the Auto-reply field.
ContactStorageTest::testContactStorage in tests/src/Functional/ContactStorageTest.php
Tests contact messages submitted through contact form.
ContactStorageTest::testMaximumSubmissionLimit in tests/src/Functional/ContactStorageTest.php
ContactStorageTest::testUrlAlias in tests/src/Functional/ContactStorageTest.php
Tests the url alias creation feature.

... See full list

File

tests/src/Functional/ContactStorageTestBase.php, line 29

Class

ContactStorageTestBase
Defines a base-class for contact-storage tests.

Namespace

Drupal\Tests\contact_storage\Functional

Code

public function addContactForm($id, $label, $recipients, $selected, $third_party_settings = [], $message = 'Your message has been sent.') {
  $this
    ->drupalGet('admin/structure/contact/add');
  $edit = [];
  $edit['label'] = $label;
  $edit['id'] = $id;

  // 8.2.x added the message field, which is by default empty. Conditionally
  // submit it if the field can be found.
  $xpath = '//textarea[@name=:value]|//input[@name=:value]|//select[@name=:value]';
  if ($this
    ->xpath($this
    ->buildXPathQuery($xpath, [
    ':value' => 'message',
  ]))) {
    $edit['message'] = $message;
  }
  $edit['recipients'] = $recipients;
  $edit['selected'] = $selected ? TRUE : FALSE;
  $edit += $third_party_settings;
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
}