diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestResultsForm.php b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestResultsForm.php new file mode 100644 index 0000000..552ab04 --- /dev/null +++ b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestResultsForm.php @@ -0,0 +1,182 @@ + array(), + 'fail' => array(), + ); + + // Summary result widget. + $form['result'] = array( + '#type' => 'fieldset', + '#title' => t('Results'), + ); + $form['result']['summary'] = $summary = array( + '#theme' => 'simpletest_result_summary', + '#pass' => 0, + '#fail' => 0, + '#exception' => 0, + '#debug' => 0, + ); + + simpletest_classloader_register(); + + // Cycle through each test group. + $header = array(t('Message'), t('Group'), t('Filename'), t('Line'), t('Function'), array('colspan' => 2, 'data' => t('Status'))); + $form['result']['results'] = array(); + foreach ($results as $group => $assertions) { + // Create group details with summary information. + $info = call_user_func(array($group, 'getInfo')); + $form['result']['results'][$group] = array( + '#type' => 'details', + '#title' => $info['name'], + '#description' => $info['description'], + ); + $form['result']['results'][$group]['summary'] = $summary; + $group_summary = &$form['result']['results'][$group]['summary']; + + // Create table of assertions for the group. + $rows = array(); + foreach ($assertions as $assertion) { + $row = array(); + $row[] = $assertion->message; + $row[] = $assertion->message_group; + $row[] = drupal_basename($assertion->file); + $row[] = $assertion->line; + $row[] = $assertion->function; + $row[] = simpletest_result_status_image($assertion->status); + + $class = 'simpletest-' . $assertion->status; + if ($assertion->message_group == 'Debug') { + $class = 'simpletest-debug'; + } + $rows[] = array('data' => $row, 'class' => array($class)); + + $group_summary['#' . $assertion->status]++; + $form['result']['summary']['#' . $assertion->status]++; + } + $form['result']['results'][$group]['table'] = array( + '#theme' => 'table', + '#header' => $header, + '#rows' => $rows, + ); + + // Set summary information. + $group_summary['#ok'] = $group_summary['#fail'] + $group_summary['#exception'] == 0; + $form['result']['results'][$group]['#collapsed'] = $group_summary['#ok']; + + // Store test group (class) as for use in filter. + $filter[$group_summary['#ok'] ? 'pass' : 'fail'][] = $group; + } + + // Overal summary status. + $form['result']['summary']['#ok'] = $form['result']['summary']['#fail'] + $form['result']['summary']['#exception'] == 0; + + // Actions. + $form['#action'] = url('admin/config/development/testing/results/re-run'); + $form['action'] = array( + '#type' => 'fieldset', + '#title' => t('Actions'), + '#attributes' => array('class' => array('container-inline')), + '#weight' => -11, + ); + + $form['action']['filter'] = array( + '#type' => 'select', + '#title' => 'Filter', + '#options' => array( + 'all' => t('All (@count)', array('@count' => count($filter['pass']) + count($filter['fail']))), + 'pass' => t('Pass (@count)', array('@count' => count($filter['pass']))), + 'fail' => t('Fail (@count)', array('@count' => count($filter['fail']))), + ), + ); + $form['action']['filter']['#default_value'] = ($filter['fail'] ? 'fail' : 'all'); + + // Categorized test classes for to be used with selected filter value. + $form['action']['filter_pass'] = array( + '#type' => 'hidden', + '#default_value' => implode(',', $filter['pass']), + ); + $form['action']['filter_fail'] = array( + '#type' => 'hidden', + '#default_value' => implode(',', $filter['fail']), + ); + + $form['action']['op'] = array( + '#type' => 'submit', + '#value' => t('Run tests'), + ); + + $form['action']['return'] = array( + '#type' => 'link', + '#title' => t('Return to list'), + '#href' => 'admin/config/development/testing', + ); + + if (is_numeric($test_id)) { + simpletest_clean_results_table($test_id); + } + + return $form; + + } + + /** + * Implements \Drupal\Core\Form\FormInterface::validateForm(). + */ + public function validateForm(array &$form, array &$form_state) { + + } + + /** + * Implements \Drupal\Core\Form\FormInterface::submitForm(). + */ + public function submitForm(array &$form, array &$form_state) { + + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + + } + +} + diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index 0a46873..97caa11 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -54,11 +54,8 @@ function simpletest_menu() { ); $items['admin/config/development/testing/results/%'] = array( 'title' => 'Test result', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('simpletest_result_form', 5), 'description' => 'View result of tests.', - 'access arguments' => array('administer unit tests'), - 'file' => 'simpletest.pages.inc', + 'router_name' => 'simpletest_result_form', ); return $items; } diff --git a/core/modules/simpletest/simpletest.routing.yml b/core/modules/simpletest/simpletest.routing.yml index 7a17bfd..fc5d8bc 100644 --- a/core/modules/simpletest/simpletest.routing.yml +++ b/core/modules/simpletest/simpletest.routing.yml @@ -4,3 +4,10 @@ simpletest_settings: _form: 'Drupal\simpletest\Form\SimpletestSettingsForm' requirements: _permission: 'administer unit tests' + +simpletest_result_form: + pattern: '/admin/config/development/testing/results/{test_id}' + defaults: + _form: 'Drupal\simpletest\Form\SimpletestResultsForm' + requirements: + _permission: 'administer unit tests'