Этот коммит содержится в:
Igor V Belousov 2015-06-10 17:15:00 +03:00
родитель 54b6791395
Коммит 49e5e71972

Просмотреть файл

@ -49,6 +49,26 @@ function batch_operations_test_page_view() {
batch_operations_start($batch);
break;
case 6:
$batch['operations'][]=array('test_batch_operation_context_finished',array());
$batch['operations'][]=array('test_batch_operation',array());
$batch['operations'][]=array('test_batch_operation',array());
batch_operations_start($batch);
break;
case 7:
$batch['operations'][]=array('test_batch_operation_params',array('a',1));
$batch['operations'][]=array('test_batch_operation_params',array('b',2));
$batch['operations'][]=array('test_batch_operation_params',array('c',3));
batch_operations_start($batch);
break;
case 8:
$batch['operations'][]=array(array('TestBatch','Operations'),array());
$batch['operations'][]=array(array('TestBatch','Operations'),array());
batch_operations_start($batch);
break;
default:
break;
}
@ -63,6 +83,9 @@ function batch_operations_test_page_view() {
<li><a href="tools.php?page=batch-operations-test&test=3">Set <strong>custom title</strong> & <strong>custom init_message</strong></a>
<li><a href="tools.php?page=batch-operations-test&test=4">5 operations default <strong>progress_message</strong></a>
<li><a href="tools.php?page=batch-operations-test&test=5">5 operations custom <strong>progress_message</strong></a>
<li><a href="tools.php?page=batch-operations-test&test=6">Test <strong>$context['finished']</strong></a>
<li><a href="tools.php?page=batch-operations-test&test=7">Test params</a>
<li><a href="tools.php?page=batch-operations-test&test=8">Test operations in class</a>
</ol>
</div>
<?php
@ -72,3 +95,33 @@ function test_batch_operation(&$context) {
sleep(1);
$context['message'] = 'Yeap! Work!';
}
function test_batch_operation_context_finished( &$context ) {
if ( empty( $context['sandbox'] ) ) {
// First run
$context['sandbox']['current_id'] = 0;
$context['sandbox']['max'] = 5 ;
}
sleep(2);
$context['message'] = 'Test $context[\'finished\']. current_id = ' . $context['sandbox']['current_id'];
$context['sandbox']['current_id']++;
if ( $context['sandbox']['current_id'] < $context['sandbox']['max'] ) {
$context['finished'] = false;
} else {
$context['finished'] = true;
}
}
function test_batch_operation_params( $a, $b, &$context ) {
sleep(2);
$context['message'] = '$a=' . $a . ' $b=' . $b ;
}
class TestBatch {
public function Operations(&$context){
sleep(2);
$context['message'] = 'class TestBatch';
}
}