You are here

protected function SimplenewsTestBase::setUpSubscribers in Simplenews 8.2

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

Setup subscribers.

Parameters

int $count: Number of subscribers to set up.

string $newsletter_id: Newsletter ID.

9 calls to SimplenewsTestBase::setUpSubscribers()
SimplenewsSendTest::setUp in tests/src/Functional/SimplenewsSendTest.php
SimplenewsSourceTest::testSendCaching in tests/src/Functional/SimplenewsSourceTest.php
Test sending a newsletter to 100 recipients with caching enabled.
SimplenewsSourceTest::testSendHidden in tests/src/Functional/SimplenewsSourceTest.php
Send a issue with the newsletter set to hidden.
SimplenewsSourceTest::testSendHtml in tests/src/Functional/SimplenewsSourceTest.php
Send a newsletter with the HTML format.
SimplenewsSourceTest::testSendMissingNode in tests/src/Functional/SimplenewsSourceTest.php
Test sending when the issue node is missing.

... See full list

File

tests/src/Functional/SimplenewsTestBase.php, line 123

Class

SimplenewsTestBase
Base class for simplenews web tests.

Namespace

Drupal\Tests\simplenews\Functional

Code

protected function setUpSubscribers($count = 100, $newsletter_id = 'default') {

  // Subscribe users.
  $this->subscribers = [];
  for ($i = 0; $i < $count; $i++) {
    $mail = $this
      ->randomEmail();
    $this->subscribers[$mail] = $mail;
  }
  $this
    ->drupalGet('admin/people/simplenews');
  $this
    ->clickLink(t('Mass subscribe'));
  $edit = [
    'emails' => implode(',', $this->subscribers),
    // @todo: Don't hardcode the default newsletter_id.
    'newsletters[' . $newsletter_id . ']' => TRUE,
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Subscribe'));
}