You are here

function CronQueueTestCase::testExceptions in Drupal 7

Tests that exceptions thrown by workers are handled properly.

File

modules/system/system.test, line 974
Tests for system.module.

Class

CronQueueTestCase
Test execution of the cron queue.

Code

function testExceptions() {
  $queue = DrupalQueue::get('cron_queue_test_exception');

  // Enqueue an item for processing.
  $queue
    ->createItem(array(
    $this
      ->randomName() => $this
      ->randomName(),
  ));

  // Run cron; the worker for this queue should throw an exception and handle
  // it.
  $this
    ->cronRun();

  // The item should be left in the queue.
  $this
    ->assertEqual($queue
    ->numberOfItems(), 1, 'Failing item still in the queue after throwing an exception.');
}