public function SimplenewsSourceTest::testSkip in Simplenews 8
Test handling of the skip exception.
File
- src/
Tests/ SimplenewsSourceTest.php, line 426 - Simplenews source test functions.
Class
- SimplenewsSourceTest
- Test cases for creating and sending newsletters.
Namespace
Drupal\simplenews\TestsCode
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' => 'default',
],
]);
\Drupal::service('simplenews.spool_storage')
->addFromEntity($node);
\Drupal::service('simplenews.mailer')
->sendSpool();
$this
->assertEqual(0, count($this
->drupalGetMails()));
$spool_row = \Drupal::database()
->select('simplenews_mail_spool', 'ms')
->fields('ms', [
'status',
])
->execute()
->fetchAssoc();
$this
->assertEqual(SpoolStorageInterface::STATUS_SKIPPED, $spool_row['status']);
}