You are here

protected function SimplenewsRecipientHandlerTest::setUp in Simplenews 8.2

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

Overrides SimplenewsTestBase::setUp

File

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

Class

SimplenewsRecipientHandlerTest
Test cases for creating and sending newsletters.

Namespace

Drupal\Tests\simplenews\Functional

Code

protected function setUp() {
  parent::setUp();

  // We install the demo module to get the recipient handlers. It creates
  // users and sends some mails so clear those first.
  $ids = \Drupal::entityQuery('user')
    ->condition('uid', 0, '>')
    ->execute();
  $storage = \Drupal::entityTypeManager()
    ->getStorage('user');
  $entities = $storage
    ->loadMultiple($ids);
  $storage
    ->delete($entities);
  simplenews_cron();
  $this->container
    ->get('state')
    ->set('system.test_mail_collector', []);
  $admin_user = $this
    ->drupalCreateUser([
    'send newsletter',
    'create simplenews_issue content',
    'edit any simplenews_issue content',
  ]);
  $this
    ->drupalLogin($admin_user);
}