You are here

protected function MassContactFormTest::verifyConfirmFormAndConfirmSendEmail in Mass Contact 8

Verifies text in the confirmation form and submits the confirmation form.

Form submission is cancelled if configs have an entry for $message_configs['cancel'].

Parameters

array $message_configs: An array of chosen message configs which decides the text in the confirmation form.

1 call to MassContactFormTest::verifyConfirmFormAndConfirmSendEmail()
MassContactFormTest::testNormalAccess in tests/src/Functional/Form/MassContactFormTest.php
Tests basic form operation on an unprivileged user.

File

tests/src/Functional/Form/MassContactFormTest.php, line 415

Class

MassContactFormTest
Tests for the Mass Contact form.

Namespace

Drupal\Tests\mass_contact\Functional\Form

Code

protected function verifyConfirmFormAndConfirmSendEmail(array $message_configs) {
  $this
    ->assertSession()
    ->pageTextContains('Are you sure you want to send this message to ' . $message_configs['user_count'] . ' user(s)?');
  if ($this->massContactUser
    ->hasPermission('mass contact administer')) {
    if ($message_configs['optout']) {
      $this
        ->assertSession()
        ->pageTextContains('You have selected to respect user opt-outs. If a user has opted out of emails they will not receive this mass contact message.');
    }
    else {
      $this
        ->assertSession()
        ->pageTextContains('You have selected to NOT respect user opt-outs. Emails will be sent to all users even if they have elected not to receive a mass contact message.');
    }
  }
  if ($this->massContactUser
    ->hasPermission('mass contact override bcc')) {
    if ($message_configs['bcc']) {
      $this
        ->assertSession()
        ->pageTextContains('Recipients of this message will be HIDDEN on the email');
    }
    else {
      $this
        ->assertSession()
        ->pageTextContains('Recipients of this message will NOT be HIDDEN on the email');
    }
  }
  if ($message_configs['copy']) {
    $this
      ->assertSession()
      ->pageTextContains('A copy of this message will be sent to you.');
  }
  else {
    $this
      ->assertSession()
      ->pageTextContains('A copy of this message will NOT be sent to you.');
  }
  if ($this->massContactUser
    ->hasPermission('mass contact override archiving')) {
    if ($message_configs['create_archive_copy']) {
      $this
        ->assertSession()
        ->pageTextContains('A copy of this message will be archived on this site.');
    }
    else {
      $this
        ->assertSession()
        ->pageTextContains('A copy of this message will NOT be archived on this site.');
    }
  }
  if (empty($message_configs['cancel'])) {
    $this
      ->drupalPostForm(NULL, [], t('Confirm'));
    $this
      ->assertSession()
      ->pageTextContains('Mass Contact message sent successfully.');
  }
  else {
    $this
      ->clickLink('Cancel');
  }
}