You are here

protected function SimplenewsRecipientHandlerTest::createUsers in Simplenews 8.2

Same name and namespace in other branches
  1. 3.x tests/src/Functional/SimplenewsRecipientHandlerTest.php \Drupal\Tests\simplenews\Functional\SimplenewsRecipientHandlerTest::createUsers()

Create some test users.

2 calls to SimplenewsRecipientHandlerTest::createUsers()
SimplenewsRecipientHandlerTest::testNewUsers in tests/src/Functional/SimplenewsRecipientHandlerTest.php
Tests the "new users" recipient handler.
SimplenewsRecipientHandlerTest::testSubscribersByRole in tests/src/Functional/SimplenewsRecipientHandlerTest.php
Tests the "subscribers by role" recipient handler.

File

tests/src/Functional/SimplenewsRecipientHandlerTest.php, line 124

Class

SimplenewsRecipientHandlerTest
Test cases for creating and sending newsletters.

Namespace

Drupal\Tests\simplenews\Functional

Code

protected function createUsers($subscribe = FALSE) {
  $subscription_manager = \Drupal::service('simplenews.subscription_manager');
  do {
    $new_user = $this
      ->drupalCreateUser([]);
    if ($subscribe) {
      $subscription_manager
        ->subscribe($new_user
        ->getEmail(), 'default', FALSE);
    }
    $users[$new_user
      ->getEmail()] = $new_user;
  } while (count($users) < 5);
  return $users;
}