You are here

public function SimplenewsSourceTest::testSkip in Simplenews 8.2

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

Test handling of the skip exception.

File

tests/src/Functional/SimplenewsSourceTest.php, line 424

Class

SimplenewsSourceTest
Test cases for creating and sending newsletters.

Namespace

Drupal\Tests\simplenews\Functional

Code

public function testSkip() {
  $this
    ->setUpSubscribers(1);

  // Setting the body to "Nothing interesting" provokes an exception in
  // simplenews_test_mail_alter().
  $node = $this
    ->drupalCreateNode([
    'body' => 'Nothing interesting',
    'type' => 'simplenews_issue',
    'simplenews_issue[target_id]' => [
      'target_id' => 'default',
    ],
  ]);
  \Drupal::service('simplenews.spool_storage')
    ->addIssue($node);
  \Drupal::service('simplenews.mailer')
    ->sendSpool();
  $this
    ->assertEqual(0, count($this
    ->getMails()));
  $spool_row = \Drupal::database()
    ->select('simplenews_mail_spool', 'ms')
    ->fields('ms', [
    'status',
  ])
    ->execute()
    ->fetchAssoc();
  $this
    ->assertEqual(SpoolStorageInterface::STATUS_SKIPPED, $spool_row['status']);
}