function ProcessingTest::_resultStack in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Batch/ProcessingTest.php \Drupal\system\Tests\Batch\ProcessingTest::_resultStack()
Returns expected execution stacks for the test batches.
7 calls to ProcessingTest::_resultStack()
- ProcessingTest::testBatchForm in core/
modules/ system/ src/ Tests/ Batch/ ProcessingTest.php - Tests batches defined in a form submit handler.
- ProcessingTest::testBatchFormMultipleBatches in core/
modules/ system/ src/ Tests/ Batch/ ProcessingTest.php - Tests batches defined in different submit handlers on the same form.
- ProcessingTest::testBatchFormMultistep in core/
modules/ system/ src/ Tests/ Batch/ ProcessingTest.php - Tests batches defined in a multistep form.
- ProcessingTest::testBatchFormProgrammatic in core/
modules/ system/ src/ Tests/ Batch/ ProcessingTest.php - Tests batches defined in a programmatically submitted form.
- ProcessingTest::testBatchLargePercentage in core/
modules/ system/ src/ Tests/ Batch/ ProcessingTest.php - Tests batches that return $context['finished'] > 1 do in fact complete.
File
- core/
modules/ system/ src/ Tests/ Batch/ ProcessingTest.php, line 196 - Contains \Drupal\system\Tests\Batch\ProcessingTest.
Class
- ProcessingTest
- Tests batch processing in form and non-form workflow.
Namespace
Drupal\system\Tests\BatchCode
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;
}