function BatchProcessingTestCase::_resultStack in Drupal 7
Helper function: return expected execution stacks for the test batches.
6 calls to BatchProcessingTestCase::_resultStack()
- BatchProcessingTestCase::testBatchForm in modules/
simpletest/ tests/ batch.test - Test batches defined in a form submit handler.
- BatchProcessingTestCase::testBatchFormMultipleBatches in modules/
simpletest/ tests/ batch.test - Test batches defined in different submit handlers on the same form.
- BatchProcessingTestCase::testBatchFormMultistep in modules/
simpletest/ tests/ batch.test - Test batches defined in a multistep form.
- BatchProcessingTestCase::testBatchFormProgrammatic in modules/
simpletest/ tests/ batch.test - Test batches defined in a programmatically submitted form.
- BatchProcessingTestCase::testBatchLargePercentage in modules/
simpletest/ tests/ batch.test - Test batches that return $context['finished'] > 1 do in fact complete. See http://drupal.org/node/600836
File
- modules/
simpletest/ tests/ batch.test, line 171 - Tests for the Batch API.
Class
- BatchProcessingTestCase
- Tests for the Batch API.
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;
}