You are here

public function UtilHelper::runBatch in Helper 7

Runs a batch even if another batch is currently running.

This is useful for running a batch inside SimpleTests.

Parameters

array $batch: A batch array that would normally get passed to batch_set().

File

lib/UtilHelper.php, line 74

Class

UtilHelper

Code

public function runBatch(array $batch) {
  $existing_batch = batch_get();
  $current_batch =& batch_get();
  if ($existing_batch) {
    $current_batch = NULL;
  }
  batch_set($batch);
  $current_batch['progressive'] = FALSE;
  batch_process();
  if ($existing_batch) {
    $current_batch = $existing_batch;
  }
}