You are here

public function OptOutTest::testOptOutGlobal in Mass Contact 8

Tests opt-out set to global.

@covers ::getOptOutAccounts

File

tests/src/Kernel/OptOutTest.php, line 124

Class

OptOutTest
Kernel tests for the opt-out service.

Namespace

Drupal\Tests\mass_contact\Kernel

Code

public function testOptOutGlobal() {

  // Global opt out.
  $this
    ->config('mass_contact.settings')
    ->set('optout_enabled', MassContactInterface::OPT_OUT_GLOBAL)
    ->save();

  /** @var \Drupal\mass_contact\OptOutInterface $opt_out */
  $opt_out = \Drupal::service('mass_contact.opt_out');
  $expected = array_merge(array_keys($this->globalOptOut), array_keys($this->categoryOptOut1), array_keys($this->categoryOptOut2));
  $expected = array_combine($expected, $expected);
  $this
    ->assertEquals($expected, $opt_out
    ->getOptOutAccounts($this->categories));
}