You are here

protected function RoleTest::setUp in Mass Contact 8

Overrides MassContactTestBase::setUp

File

tests/src/Kernel/Plugin/MassContact/GroupingMethod/RoleTest.php, line 45

Class

RoleTest
Tests the role grouping method plugin.

Namespace

Drupal\Tests\mass_contact\Kernel\Plugin\MassContact\GroupingMethod

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('user');
  $this
    ->installSchema('system', [
    'sequences',
  ]);

  // Add 3 roles.
  foreach (range(1, 3) as $i) {
    $rid = $this
      ->createRole([]);
    $this->roles[$i] = UserRole::load($rid);
  }

  // Create 10 users, and add their roles.
  foreach (range(1, 10) as $i) {
    $this->recipients[$i] = $this
      ->createUser([]);
    $this->recipients[$i]
      ->addRole($this->roles[2]
      ->id());

    // Block user 4.
    if ($i == 4) {
      $this->recipients[$i]
        ->block();
    }
    $this->recipients[$i]
      ->save();
  }
  $this->groupingManager = \Drupal::service('plugin.manager.mass_contact.grouping_method');
}