You are here

public function SparkpostTestCase::testSkipQueueOnCron in Sparkpost email 7

Same name and namespace in other branches
  1. 7.2 tests/sparkpost.test \SparkpostTestCase::testSkipQueueOnCron()

Test that queue is not processed on cron, if indicated by settings.

File

tests/sparkpost.test, line 88
Test class for the Sparkpost module.

Class

SparkpostTestCase
@file Test class for the Sparkpost module.

Code

public function testSkipQueueOnCron() {
  variable_set('sparkpost_skip_cron', FALSE);
  variable_set('sparkpost_send_async', TRUE);

  /** @var DrupalQueueInterface $queue */
  $queue = DrupalQueue::get(SPARKPOST_QUEUE_NAME);

  // Create a dummy item.
  $queue
    ->createItem($this
    ->createDummyMessage());
  $this
    ->assertEqual($queue
    ->numberOfItems(), 1);

  // Run cron.
  $this
    ->cronRun();

  // Should have processed the item.
  $this
    ->assertEqual($queue
    ->numberOfItems(), 0);
  variable_set('sparkpost_skip_cron', TRUE);
  $queue
    ->createItem($this
    ->createDummyMessage());
  $this
    ->assertEqual($queue
    ->numberOfItems(), 1);

  // Run cron.
  $this
    ->cronRun();

  // Should not have processed the item.
  $this
    ->assertEqual($queue
    ->numberOfItems(), 1);
}