summaryrefslogtreecommitdiff
path: root/modules/simpletest/simpletest.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-11-01 18:32:22 +0000
committerDries Buytaert <dries@buytaert.net>2008-11-01 18:32:22 +0000
commit4a6243aff27d5f26189e0e9eff2039fe0cdbb754 (patch)
treefae2f3a71f6cdd95786fc9bbb6ba463955dc7647 /modules/simpletest/simpletest.module
parent39f4e0ebcd3192a4459afb0c5965c979651687b6 (diff)
downloadbrdo-4a6243aff27d5f26189e0e9eff2039fe0cdbb754.tar.gz
brdo-4a6243aff27d5f26189e0e9eff2039fe0cdbb754.tar.bz2
- Patch #314401 by boombatower et al: batch API screen improvements.
Diffstat (limited to 'modules/simpletest/simpletest.module')
-rw-r--r--modules/simpletest/simpletest.module39
1 files changed, 24 insertions, 15 deletions
diff --git a/modules/simpletest/simpletest.module b/modules/simpletest/simpletest.module
index bc51a6899..896b64f61 100644
--- a/modules/simpletest/simpletest.module
+++ b/modules/simpletest/simpletest.module
@@ -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.'));
}