public function SimplenewsSourceTest::testSendMissingSubscriber in Simplenews 8.2
Same name and namespace in other branches
- 3.x tests/src/Functional/SimplenewsSourceTest.php \Drupal\Tests\simplenews\Functional\SimplenewsSourceTest::testSendMissingSubscriber()
Test sending when there are no subscribers.
File
- tests/
src/ Functional/ SimplenewsSourceTest.php, line 393
Class
- SimplenewsSourceTest
- Test cases for creating and sending newsletters.
Namespace
Drupal\Tests\simplenews\FunctionalCode
public function testSendMissingSubscriber() {
$this
->setUpSubscribers(1);
$edit = [
'title[0][value]' => $this
->randomString(10),
'body[0][value]' => "Mail token: <strong>[simplenews-subscriber:mail]</strong>",
'simplenews_issue[target_id]' => 'default',
];
$this
->drupalPostForm('node/add/simplenews_issue', $edit, 'Save');
$this
->assertEqual(1, preg_match('|node/(\\d+)$|', $this
->getUrl(), $matches), 'Node created');
$node = Node::load($matches[1]);
// Add node to spool.
\Drupal::service('simplenews.spool_storage')
->addIssue($node);
// Delete the subscriber.
$subscriber = Subscriber::loadByMail(reset($this->subscribers));
$subscriber
->delete();
\Drupal::service('simplenews.mailer')
->sendSpool();
// Make sure that no mails have been sent.
$this
->assertEqual(0, count($this
->getMails()));
$spool_row = \Drupal::database()
->query('SELECT * FROM {simplenews_mail_spool}')
->fetchObject();
$this
->assertEqual(SpoolStorageInterface::STATUS_SKIPPED, $spool_row->status);
}