function CronQueueTestCase::testExceptions

Tests that exceptions thrown by workers are handled properly.

File

modules/system/system.test, line 990

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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.