function ProcessingTest::_resultStack

Returns expected execution stacks for the test batches.

6 calls to ProcessingTest::_resultStack()
ProcessingTest::testBatchForm in drupal/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php
Tests batches defined in a form submit handler.
ProcessingTest::testBatchFormMultipleBatches in drupal/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php
Tests batches defined in different submit handlers on the same form.
ProcessingTest::testBatchFormMultistep in drupal/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php
Tests batches defined in a multistep form.
ProcessingTest::testBatchFormProgrammatic in drupal/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php
Tests batches defined in a programmatically submitted form.
ProcessingTest::testBatchLargePercentage in drupal/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php
Tests batches that return $context['finished'] > 1 do in fact complete.

... See full list

File

drupal/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php, line 181
Definition of Drupal\system\Tests\Batch\ProcessingTest.

Class

ProcessingTest
Tests the Batch API.

Namespace

Drupal\system\Tests\Batch

Code

function _resultStack($id, $value = 0) {
  $stack = array();
  switch ($id) {
    case 'batch_1':
      for ($i = 1; $i <= 10; $i++) {
        $stack[] = "op 1 id {$i}";
      }
      break;
    case 'batch_2':
      for ($i = 1; $i <= 10; $i++) {
        $stack[] = "op 2 id {$i}";
      }
      break;
    case 'batch_3':
      for ($i = 1; $i <= 5; $i++) {
        $stack[] = "op 1 id {$i}";
      }
      for ($i = 1; $i <= 5; $i++) {
        $stack[] = "op 2 id {$i}";
      }
      for ($i = 6; $i <= 10; $i++) {
        $stack[] = "op 1 id {$i}";
      }
      for ($i = 6; $i <= 10; $i++) {
        $stack[] = "op 2 id {$i}";
      }
      break;
    case 'batch_4':
      for ($i = 1; $i <= 5; $i++) {
        $stack[] = "op 1 id {$i}";
      }
      $stack[] = 'setting up batch 2';
      for ($i = 6; $i <= 10; $i++) {
        $stack[] = "op 1 id {$i}";
      }
      $stack = array_merge($stack, $this
        ->_resultStack('batch_2'));
      break;
    case 'batch_5':
      for ($i = 1; $i <= 10; $i++) {
        $stack[] = "op 5 id {$i}";
      }
      break;
    case 'chained':
      $stack[] = 'submit handler 1';
      $stack[] = 'value = ' . $value;
      $stack = array_merge($stack, $this
        ->_resultStack('batch_1'));
      $stack[] = 'submit handler 2';
      $stack[] = 'value = ' . ($value + 1);
      $stack = array_merge($stack, $this
        ->_resultStack('batch_2'));
      $stack[] = 'submit handler 3';
      $stack[] = 'value = ' . ($value + 2);
      $stack[] = 'submit handler 4';
      $stack[] = 'value = ' . ($value + 3);
      $stack = array_merge($stack, $this
        ->_resultStack('batch_3'));
      break;
  }
  return $stack;
}