You are here

function SimplenewsSourceTestCase::testSendMissingSubscriber in Simplenews 7.2

Same name and namespace in other branches
  1. 7 tests/simplenews.test \SimplenewsSourceTestCase::testSendMissingSubscriber()

Test with disabled caching.

File

tests/simplenews.test, line 3056
Simplenews test functions.

Class

SimplenewsSourceTestCase
Test cases for creating and sending newsletters.

Code

function testSendMissingSubscriber() {
  $this
    ->setUpSubscribers(1);
  $edit = array(
    'title' => $this
      ->randomName(),
    'body[und][0][value]' => "Mail token: <strong>[simplenews-subscriber:mail]</strong>",
  );
  $this
    ->drupalPost('node/add/simplenews', $edit, 'Save');
  $this
    ->assertTrue(preg_match('|node/(\\d+)$|', $this
    ->getUrl(), $matches), 'Node created');
  $node = node_load($matches[1]);

  // Add node to spool.
  simplenews_add_node_to_spool($node);

  // Delete the subscriber.
  $subscriber = simplenews_subscriber_load_by_mail(reset($this->subscribers));
  simplenews_subscriber_delete($subscriber->snid);
  simplenews_mail_spool();

  // Make sure that no mails have been sent.
  $this
    ->assertEqual(0, count($this
    ->drupalGetMails()));
  $spool_row = db_query('SELECT * FROM {simplenews_mail_spool}')
    ->fetchObject();
  $this
    ->assertEqual(SIMPLENEWS_SPOOL_DONE, $spool_row->status);
}