Commit 4a6243af authored by Dries's avatar Dries

- Patch #314401 by boombatower et al: batch API screen improvements.

parent 39f4e0eb
......@@ -255,8 +255,11 @@ function _batch_process() {
'@total' => $total,
'@current' => floor($current),
'@percentage' => $percentage,
);
$message = strtr($progress_message, $values) . '<br/>';
);
$message = strtr($progress_message, $values);
if (!empty($message)) {
$message .= '<br/>';
}
$message .= $task_message ? $task_message : '&nbsp';
return array($percentage, $message);
......
......@@ -3,30 +3,36 @@
/* Addon for the simpletest module */
#simpletest {
}
/* Test Table */
#simpletest-form-table th.select-all {
width: 50px;
}
th.simpletest_test {
width: 160px;
}
table#simpletest-form-table tr td {
background-color: white !important;
background-color: white;
color: #494949;
}
table#simpletest-form-table tr.simpletest-group td {
background-color: #EDF5FA !important;
background-color: #EDF5FA;
color: #494949;
}
div.message > div.item-list {
font-weight: normal;
}
div.simpletest-pass {
color: #33a333;
}
div.simpletest-fail {
color: #a30000;
.simpletest-fail {
color: #981010;
}
tr.simpletest-pass.odd {
......
......@@ -214,16 +214,16 @@ function theme_simpletest_test_table($table) {
// Create header for test selection table.
$header = array(
theme('table_select_header_cell'),
array('data' => t('Test'), 'class' => 'simpletest_test'),
array('data' => t('Description'), 'class' => 'simpletest_description'),
theme('table_select_header_cell'),
array('data' => t('Test'), 'class' => 'simpletest_test'),
array('data' => t('Description'), 'class' => 'simpletest_description'),
);
// Define the images used to expand/collapse the test groups.
$js = array(
'images' => array(
0 => theme('image', 'misc/menu-collapsed.png', 'Expand', 'Expand'),
1 => theme('image', 'misc/menu-expanded.png', 'Collapsed', 'Collapsed'),
theme('image', 'misc/menu-collapsed.png', 'Expand', 'Expand'),
theme('image', 'misc/menu-expanded.png', 'Collapsed', 'Collapsed'),
),
);
......@@ -303,7 +303,7 @@ function theme_simpletest_result_summary($form, $text = NULL) {
}
function _simpletest_format_summary_line($summary) {
return t('@pass, @fail, @exception', array(
return t('@pass, @fail, and @exception', array(
'@pass' => format_plural(isset($summary['#pass']) ? $summary['#pass'] : 0, '1 pass', '@count passes'),
'@fail' => format_plural(isset($summary['#fail']) ? $summary['#fail'] : 0, '1 fail', '@count fails'),
'@exception' => format_plural(isset($summary['#exception']) ? $summary['#exception'] : 0, '1 exception', '@count exceptions'),
......@@ -333,7 +333,8 @@ function simpletest_test_form_submit($form, &$form_state) {
}
/**
* Actually runs tests
* Actually runs tests.
*
* @param $test_list
* List of tests to run.
* @param $reporter
......@@ -345,6 +346,12 @@ function simpletest_run_tests($test_list, $reporter = 'drupal') {
cache_clear_all();
$test_id = db_insert('simpletest_test_id')->useDefaults(array('test_id'))->execute();
// Get the info for the first test being run.
$first_test = array_shift($test_list);
$first_instance = new $first_test();
array_unshift($test_list, $first_test);
$info = $first_instance->getInfo();
$batch = array(
'title' => t('Running SimpleTests'),
'operations' => array(
......@@ -352,9 +359,10 @@ function simpletest_run_tests($test_list, $reporter = 'drupal') {
),
'finished' => '_simpletest_batch_finished',
'redirect' => 'admin/build/testing',
'progress_message' => t('Processing tests.'),
'progress_message' => '',
'css' => array(drupal_get_path('module', 'simpletest') . '/simpletest.css'),
'init_message' => t('SimpleTest is initializing...') . ' ' . format_plural(count($test_list), "one test case will run.", "@count test cases will run."),
'js' => array(drupal_get_path('module', 'simpletest') .'/simpletest.js'),
'init_message' => t('Processing test @num of @max - %test.', array('%test' => $info['name'], '@num' => '1', '@max' => count($test_list))),
);
batch_set($batch);
// Normally, the forms portion of the batch API takes care of calling
......@@ -402,12 +410,11 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) {
$test_results[$test_class]['#name'] = $info['name'];
$items = array();
foreach (element_children($test_results) as $class) {
$items[] = '<div class="simpletest-' . ($test_results[$class]['#fail'] + $test_results[$class]['#exception'] ? 'fail' : 'pass') . '">' . t('@name: @summary', array('@name' => $test_results[$class]['#name'], '@summary' => _simpletest_format_summary_line($test_results[$class]))) . '</div>';
array_unshift($items, '<div class="simpletest-' . ($test_results[$class]['#fail'] + $test_results[$class]['#exception'] ? 'fail' : 'pass') . '">' . t('@name: @summary', array('@name' => $test_results[$class]['#name'], '@summary' => _simpletest_format_summary_line($test_results[$class]))) . '</div>');
}
$message = t('Processed test @num of @max - %test.', array('%test' => $info['name'], '@num' => $max - $size, '@max' => $max));
$message .= theme('item_list', $items);
$context['message'] = $message;
// TODO: Do we want a summary of all?
$context['message'] = t('Processed test @num of @max - %test.', array('%test' => $info['name'], '@num' => $max - $size, '@max' => $max));
$context['message'] .= '<div class="simpletest-' . ($test_results['#fail'] + $test_results['#exception'] ? 'fail' : 'pass') . '">Overall results: ' . _simpletest_format_summary_line($test_results) . '</div>';
$context['message'] .= theme('item_list', $items);
// Save working values for the next iteration.
$context['sandbox']['tests'] = $test_list;
......@@ -420,7 +427,9 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) {
}
function _simpletest_batch_finished($success, $results, $operations) {
$_SESSION['test_id'] = $results['test_id'];
if (isset($results['test_id'])) {
$_SESSION['test_id'] = $results['test_id'];
}
if ($success) {
drupal_set_message(t('The tests have finished running.'));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment