You are here

public function SimplenewsRecipientHandlerTest::testSiteMail in Simplenews 3.x

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

Tests the "site mail" recipient handler.

File

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

Class

SimplenewsRecipientHandlerTest
Test cases for creating and sending newsletters.

Namespace

Drupal\Tests\simplenews\Functional

Code

public function testSiteMail() {

  // Verify that the recipient handler settings are shown.
  $this
    ->drupalGet('node/add/simplenews_issue');
  $this
    ->assertText(t('Recipients'));
  $this
    ->assertText(t('How recipients should be selected.'));
  $edit = [
    'title[0][value]' => $this
      ->randomString(10),
    'simplenews_issue[target_id]' => 'default',
    'simplenews_issue[handler]' => 'simplenews_site_mail',
  ];
  $this
    ->submitForm($edit, 'Save');
  $this
    ->clickLink(t('Newsletter'));
  $this
    ->assertText(t('Send newsletter issue to 1 subscribers.'));
  $this
    ->submitForm([], 'Send now');
  $this
    ->checkRecipients([
    'simpletest@example.com' => 1,
  ]);
}