Index: includes/batch.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/batch.inc,v retrieving revision 1.20 diff -u -p -r1.20 batch.inc --- includes/batch.inc 24 Jun 2008 21:51:02 -0000 1.20 +++ includes/batch.inc 25 Jun 2008 02:59:32 -0000 @@ -22,11 +22,14 @@ function _batch_page() { // Register database update for end of processing. register_shutdown_function('_batch_shutdown'); - // Add batch-specific css. + // Add batch-specific css and javascript. foreach ($batch['sets'] as $batch_set) { foreach ($batch_set['css'] as $css) { drupal_add_css($css); } + foreach ($batch_set['js'] as $js) { + drupal_add_js($js); + } } $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : ''; Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.277 diff -u -p -r1.277 form.inc --- includes/form.inc 18 Jul 2008 07:06:24 -0000 1.277 +++ includes/form.inc 26 Jul 2008 04:46:35 -0000 @@ -2421,6 +2421,7 @@ function batch_set($batch_definition) { 'progress_message' => $t('Remaining @remaining of @total.'), 'error_message' => $t('An error has occurred.'), 'css' => array(), + 'js' => array(), ); $batch_set = $init + $batch_definition + $defaults; Index: misc/batch.js =================================================================== RCS file: /cvs/drupal/drupal/misc/batch.js,v retrieving revision 1.4 diff -u -p -r1.4 batch.js --- misc/batch.js 21 Oct 2007 18:59:01 -0000 1.4 +++ misc/batch.js 4 Jul 2008 05:35:13 -0000 @@ -16,6 +16,9 @@ Drupal.behaviors.batch = function (conte // Success: redirect to the summary. var updateCallback = function (progress, status, pb) { + for (behavior in Drupal.batchUpdate) { + Drupal.batchUpdate[behavior](progress, status, pb); + } if (progress == 100) { pb.stopMonitoring(); window.location = uri+'&op=finished'; @@ -35,4 +38,4 @@ Drupal.behaviors.batch = function (conte $(holder).append(progress.element); progress.startMonitoring(uri+'&op=do', 10); }); -}; +}; \ No newline at end of file Index: misc/drupal.js =================================================================== RCS file: /cvs/drupal/drupal/misc/drupal.js,v retrieving revision 1.45 diff -u -p -r1.45 drupal.js --- misc/drupal.js 25 Jun 2008 07:45:03 -0000 1.45 +++ misc/drupal.js 26 Jul 2008 05:47:52 -0000 @@ -1,6 +1,6 @@ // $Id: drupal.js,v 1.45 2008/06/25 07:45:03 dries Exp $ -var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'themes': {}, 'locale': {} }; +var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'themes': {}, 'locale': {}, 'batchUpdate': {} }; /** * Set the variable that indicates if JavaScript behaviors should be applied Index: modules/simpletest/drupal_web_test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v retrieving revision 1.27 diff -u -p -r1.27 drupal_web_test_case.php --- modules/simpletest/drupal_web_test_case.php 18 Jul 2008 07:30:34 -0000 1.27 +++ modules/simpletest/drupal_web_test_case.php 27 Jul 2008 04:01:49 -0000 @@ -62,6 +62,7 @@ class DrupalWebTestCase { if (substr($function['function'], 0, 6) != 'assert' && $function['function'] != 'pass' && $function['function'] != 'fail') { break; } + $previous_function = $function; } } else { @@ -75,8 +76,8 @@ class DrupalWebTestCase { 'message' => $message, 'group' => $group, 'function' => $function['function'], - 'line' => $function['line'], - 'file' => $function['file'], + 'line' => $previous_function['line'], + 'file' => $previous_function['file'], ); $db_prefix = $current_db_prefix; return $status; @@ -304,6 +305,7 @@ class DrupalWebTestCase { 'file' => $file, )); } + drupal_set_message(var_export($severity, TRUE)); return TRUE; } @@ -710,7 +712,6 @@ class DrupalWebTestCase { // Close the CURL handler. $this->curlClose(); - restore_error_handler(); } } @@ -785,7 +786,7 @@ class DrupalWebTestCase { // them. @$htmlDom = DOMDocument::loadHTML($this->_content); if ($htmlDom) { - $this->assertTrue(TRUE, t('Valid HTML found on "@path"', array('@path' => $this->getUrl())), t('Browser')); + $this->pass(t('Valid HTML found on "@path"', array('@path' => $this->getUrl())), t('Browser')); // It's much easier to work with simplexml than DOM, luckily enough // we can just simply import our DOM tree. $this->elements = simplexml_import_dom($htmlDom); @@ -1183,7 +1184,7 @@ class DrupalWebTestCase { * TRUE on pass, FALSE on fail. */ function assertText($text, $message = '', $group = 'Other') { - return $this->assertTextHelper($text, $message, $group = 'Other', FALSE); + return $this->assertTextHelper($text, $message, $group, FALSE); } /** Index: modules/simpletest/simpletest.css =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.css,v retrieving revision 1.2 diff -u -p -r1.2 simpletest.css --- modules/simpletest/simpletest.css 24 Jun 2008 21:51:02 -0000 1.2 +++ modules/simpletest/simpletest.css 27 Jul 2008 04:48:35 -0000 @@ -1,8 +1,5 @@ /* $Id: simpletest.css,v 1.2 2008/06/24 21:51:02 dries Exp $ */ -/* Addon for the simpletest module */ -#simpletest { -} /* Test Table */ th.simpletest_run { width: 50px; @@ -17,46 +14,51 @@ td.simpletest-select-all { } table#simpletest-form-table tr td { - background-color: white !important; + background-color: white; } table#simpletest-form-table tr.simpletest-group td { - background-color: #EDF5FA !important; -} - -div.simpletest-pass { - color: #33a333; + background-color: #EDF5FA; } -div.simpletest-fail { - color: #a30000; +div.simpletest-image { + display: inline; + cursor: pointer; } -tr.simpletest-pass.odd { - background: #b6ffb6; +.item-list ul li.simpletest-pass { + color: #316d31; + list-style-image: url(../../misc/watchdog-ok.png); + list-style-position: inside; + background-image: none; } -tr.simpletest-pass.even { - background: #9bff9b; +.item-list ul li.simpletest-fail { + color: #981010; + list-style-image: url(../../misc/watchdog-error.png); + list-style-position: inside; + background-image: none; } -tr.simpletest-fail.odd { - background: #ffc9c9; +.item-list ul li.simpletest-exception { + color: #bda400; + list-style-image: url(../../misc/watchdog-warning.png); + list-style-position: inside; + background-image: none; } -tr.simpletest-fail.even { - background: #ffacac; +div.message > div.item-list { + font-weight: normal; } -tr.simpletest-exception.odd { - background: #f4ea71; +li.simpletest-important { + font-weight: bold; } -tr.simpletest-exception.even { - background: #f5e742; +ul.simpletest-results li div.item-list ul { + padding-left: 20px; } -div.simpletest-image { - display: inline; +ul.simpletest-results li span.simpletest-overview { cursor: pointer; -} +} \ No newline at end of file Index: modules/simpletest/simpletest.js =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.js,v retrieving revision 1.2 diff -u -p -r1.2 simpletest.js --- modules/simpletest/simpletest.js 23 Apr 2008 18:50:49 -0000 1.2 +++ modules/simpletest/simpletest.js 26 Jul 2008 05:49:49 -0000 @@ -27,6 +27,7 @@ Drupal.behaviors.simpleTestMenuCollapse } }); } + Drupal.behaviors.simpleTestSelectAll = function() { $('td.simpletest-select-all').each(function() { var checkboxes = Drupal.settings.simpleTest['simpletest-test-group-'+ $(this).attr('id')].testNames, totalCheckboxes = 0, @@ -60,4 +61,40 @@ Drupal.behaviors.simpleTestSelectAll = f } $(this).append(checkbox); }); +}; + +Drupal.behaviors.simpleTestFilterForm = function() { + var updateResults = function(type, checked) { + $('.simpletest-' + type + ':not(.simpletest-hidden)')[checked ? 'show' : 'hide'](); + } + $('#edit-outcome-pass').change(function() { + updateResults('pass', $(this).is(':checked')); + }); + $('#edit-outcome-fail').change(function() { + updateResults('fail', $(this).is(':checked')); + }); + $('#edit-outcome-exception').change(function() { + updateResults('exception', $(this).is(':checked')); + }); + updateResults('pass', $('#edit-outcome-pass').is(':checked')); + updateResults('fail', $('#edit-outcome-fail').is(':checked')); + updateResults('exception', $('#edit-outcome-exception').is(':checked')); +}; + +Drupal.behaviors.simpleTestResultsCollapse = function() { + $('li > span.simpletest-overview').click(function() { + $(this).siblings().children('ul').toggle().toggleClass('simpletest-hidden'); + }); + $('li > span.simpletest-overview').each(function() { + $(this).siblings().children('ul').hide().addClass('simpletest-hidden'); + }); +}; + +Drupal.batchUpdate.simpleTestResultsCollapse = function() { + $('li > span.simpletest-overview').click(function() { + $(this).siblings().children('ul').toggle().toggleClass('simpletest-hidden'); + }); + $('li > span.simpletest-overview').each(function() { + $(this).siblings().children('ul').hide().addClass('simpletest-hidden'); + }); }; \ No newline at end of file Index: modules/simpletest/simpletest.module =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.module,v retrieving revision 1.7 diff -u -p -r1.7 simpletest.module --- modules/simpletest/simpletest.module 16 Jul 2008 21:59:27 -0000 1.7 +++ modules/simpletest/simpletest.module 27 Jul 2008 04:55:48 -0000 @@ -50,6 +50,9 @@ function simpletest_theme() { 'simpletest_result_summary' => array( 'arguments' => array('form' => NULL) ), + 'simpletest_results' => array( + 'arguments' => array('results' => NULL, 'assertions' => NULL), + ), ); } @@ -62,84 +65,33 @@ function simpletest_test_form() { $uncategorized_tests = simpletest_get_all_tests(); $tests = simpletest_categorize_tests($uncategorized_tests); if (isset($_SESSION['test_id'])) { + $form['#test_id'] = $_SESSION['test_id']; $results = db_query("SELECT * FROM {simpletest} WHERE test_id = %d ORDER BY test_class, message_id", $_SESSION['test_id']); unset($_SESSION['test_id']); - $summary = array( - '#theme' => 'simpletest_result_summary', - '#pass' => 0, - '#fail' => 0, - '#exception' => 0, - '#weight' => -10, - ); - $form['summary'] = $summary; - $form['results'] = array(); - $group_summary = array(); - $map = array( - 'pass' => theme('image', 'misc/watchdog-ok.png'), - 'fail' => theme('image', 'misc/watchdog-error.png'), - 'exception' => theme('image', 'misc/watchdog-warning.png'), - ); $header = array(t('Message'), t('Group'), t('Filename'), t('Line'), t('Function'), array('colspan' => 2, 'data' => t('Status'))); + $test_results = array(); + $test_assertions = array(); while ($result = db_fetch_object($results)) { - $class = $result->test_class; - $info = $uncategorized_tests[$class]->getInfo(); - $group = $info['group']; - if (!isset($group_summary[$group])) { - $group_summary[$group] = $summary; - } - $element = &$form['results'][$group][$class]; - if (!isset($element)) { - $element['summary'] = $summary; - } - $status = $result->status; - // This reporter can only handle pass, fail and exception. - if (isset($map[$status])) { - $element['#title'] = $info['name']; - $status_index = '#'. $status; - $form['summary'][$status_index]++; - $group_summary[$group][$status_index]++; - $element['summary'][$status_index]++; - $element['result_table']['#rows'][] = array( - 'data' => array( - $result->message, - $result->message_group, - basename($result->file), - $result->line, - $result->caller, - $map[$status], - ), - 'class' => "simpletest-$status", - ); + if (empty($test_results[$result->test_class])) { + $class = $result->test_class; + $test = new $class(); + $info = $test->getInfo(); + $test_results[$class] = array('#fail' => 0, '#pass' => 0, '#exception' => 0); + foreach ($info as $key => $value) { + $test_results[$class]['#' . $key] = $value; + } } - unset($element); + $test_results[$result->test_class]['#' . $result->status]++; + $assertion = (array)$result; + $assertion['group'] = $assertion['message_group']; + unset($assertion['message_group']); + $assertion['function'] = $assertion['caller']; + unset($assertion['caller']); + $test_assertions[$result->test_class][] = $assertion; + $test_results[$class]['#ok'] = !($test_results[$class]['#fail'] + $test_results[$class]['#exception']); } - $all_ok = TRUE; - foreach ($form['results'] as $group => &$elements) { - $group_ok = TRUE; - foreach ($elements as $class => &$element) { - $info = $uncategorized_tests[$class]->getInfo(); - $ok = $element['summary']['#fail'] + $element['summary']['#exception'] == 0; - $element += array( - '#type' => 'fieldset', - '#collapsible' => TRUE, - '#collapsed' => $ok, - '#description' => $info['description'], - ); - $element['result_table']['#markup'] = theme('table', $header, $element['result_table']['#rows']); - $element['summary']['#ok'] = $ok; - $group_ok = $group_ok && $ok; - } - $elements += array( - '#type' => 'fieldset', - '#title' => $group, - '#collapsible' => TRUE, - '#collapsed' => $group_ok, - 'summary' => $group_summary[$group], - ); - $elements['summary']['#ok'] = $group_ok; - $all_ok = $group_ok && $all_ok; - } - $form['summary']['#ok'] = $all_ok; + $form['#results'] = $test_results; + $form['#assertions'] = $test_assertions; } foreach ($tests as $group_name => $test_group) { foreach ($test_group as $test) { @@ -164,8 +116,8 @@ function simpletest_test_form() { '#type' => 'radios', '#default_value' => 'selected_tests', '#options' => array( - 'all_tests' => t('Run all tests (WARNING, this may take a long time)'), 'selected_tests' => t('Run selected tests'), + 'all_tests' => t('Run all tests'), ), ); $form['run']['op'] = array( @@ -195,6 +147,7 @@ function simpletest_test_form() { function theme_simpletest_test_form($form) { drupal_add_css(drupal_get_path('module', 'simpletest') .'/simpletest.css', 'module'); drupal_add_js(drupal_get_path('module', 'simpletest') .'/simpletest.js', 'module'); + $header = array( array('data' => t('Run'), 'class' => 'simpletest_run checkbox'), array('data' => t('Test'), 'class' => 'simpletest_test'), @@ -243,9 +196,15 @@ function theme_simpletest_test_form($for drupal_add_js(array('simpleTest' => $js), 'setting'); // Output test groups: $output = ''; - if (isset($form['results'])) { - $output .= drupal_render($form['summary']); - $output .= drupal_render($form['results']); + if (isset($form['#results'])) { + $output .= drupal_get_form('simpletest_filter_form'); + $output .= theme('simpletest_results', $form['#results'], $form['#assertions']); + $output .= drupal_get_form('simpletest_rerun_form', $form['#test_id']); + return $output; + } + else { + // This will forward us to the batch api if necessary. + drupal_get_form('simpletest_rerun_form', NULL); } if (count($rows)) { $output .= theme('table', $header, $rows, array('id' => 'simpletest-form-table')); @@ -256,12 +215,8 @@ function theme_simpletest_test_form($for return $output; } -function theme_simpletest_result_summary($form, $text = NULL) { - return '