diff -r 07239de796bb -r e756a8c72c3d cms/drupal/modules/simpletest/tests/batch_test.callbacks.inc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cms/drupal/modules/simpletest/tests/batch_test.callbacks.inc Fri Sep 08 12:04:06 2017 +0200 @@ -0,0 +1,163 @@ + 1 + $context['finished'] = 3.14; +} + +/** + * Implements callback_batch_operation(). + * + * Batch operation setting up its own batch. + */ +function _batch_test_nested_batch_callback() { + batch_test_stack('setting up batch 2'); + batch_set(_batch_test_batch_2()); +} + +/** + * Implements callback_batch_finished(). + * + * Common 'finished' callbacks for batches 1 to 4. + */ +function _batch_test_finished_helper($batch_id, $success, $results, $operations) { + $messages = array("results for batch $batch_id"); + if ($results) { + foreach ($results as $op => $op_results) { + $messages[] = 'op '. $op . ': processed ' . count($op_results) . ' elements'; + } + } + else { + $messages[] = 'none'; + } + + if (!$success) { + // A fatal error occurred during the processing. + $error_operation = reset($operations); + $messages[] = t('An error occurred while processing @op with arguments:
@args', array('@op' => $error_operation[0], '@args' => print_r($error_operation[1], TRUE))); + } + + drupal_set_message(implode('
', $messages)); +} + +/** + * Implements callback_batch_finished(). + * + * 'finished' callback for batch 0. + */ +function _batch_test_finished_0($success, $results, $operations) { + _batch_test_finished_helper(0, $success, $results, $operations); +} + +/** + * Implements callback_batch_finished(). + * + * 'finished' callback for batch 1. + */ +function _batch_test_finished_1($success, $results, $operations) { + _batch_test_finished_helper(1, $success, $results, $operations); +} + +/** + * Implements callback_batch_finished(). + * + * 'finished' callback for batch 2. + */ +function _batch_test_finished_2($success, $results, $operations) { + _batch_test_finished_helper(2, $success, $results, $operations); +} + +/** + * Implements callback_batch_finished(). + * + * 'finished' callback for batch 3. + */ +function _batch_test_finished_3($success, $results, $operations) { + _batch_test_finished_helper(3, $success, $results, $operations); +} + +/** + * Implements callback_batch_finished(). + * + * 'finished' callback for batch 4. + */ +function _batch_test_finished_4($success, $results, $operations) { + _batch_test_finished_helper(4, $success, $results, $operations); +} + +/** + * Implements callback_batch_finished(). + * + * 'finished' callback for batch 5. + */ +function _batch_test_finished_5($success, $results, $operations) { + _batch_test_finished_helper(5, $success, $results, $operations); +}