You are here

public function ContactAjaxTest::testContactAjax in Contact ajax 8

Tests contact messages submitted through contact form.

File

tests/src/FunctionalJavascript/ContactAjaxTest.php, line 38

Class

ContactAjaxTest
Tests contact form ajax submission.

Namespace

Drupal\Tests\contact_ajax\FunctionalJavascript

Code

public function testContactAjax() {
  $this
    ->drupalPlaceBlock('system_breadcrumb_block');
  $this
    ->drupalPlaceBlock('local_actions_block');
  $this
    ->drupalPlaceBlock('page_title_block');

  // Create and login administrative user.
  $admin_user = $this
    ->drupalCreateUser([
    'access site-wide contact form',
    'administer contact forms',
    'administer users',
    'administer account settings',
    'administer contact_message fields',
    'administer contact_message form display',
    'administer contact_message display',
  ]);
  $this
    ->drupalLogin($admin_user);

  // Test if ajax settings has been added.
  $this
    ->drupalGet('admin/structure/contact/add');
  $this
    ->assertSession()
    ->pageTextContains(t('Ajax Form'));
  $this
    ->configureContactAjax();
  $this
    ->sendContactAjax();
}