diff -u b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestTestForm.php b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestTestForm.php --- b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestTestForm.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestTestForm.php @@ -7,6 +7,8 @@ namespace Drupal\simpletest\Form; +use Drupal\Component\Utility\SortArray; +use Drupal\Component\Utility\String; use Drupal\Core\Form\FormBase; /** @@ -53,39 +55,44 @@ $form['tests']['table'] = array( '#type' => 'table', - '#attached' => array('library' => array(array('simpletest', 'drupal.simpletest'))), - '#header' => array( - array('class' => array('select-all')), - array('data' => t('Test'), 'class' => array('simpletest_test')), - array('data' => t('Description'), 'class' => array('simpletest_description')), + '#id' => 'simpletest-form-table', + '#tableselect' => TRUE, + '#parents' => array(), + '#header' => array($this->t('Test'), $this->t('Description')), + '#empty' => $this->t('No tests to display.'), + '#attached' => array( + 'library' => array( + array('simpletest', 'drupal.simpletest'), + ), ), - '#empty' => '' . t('No tests to display.') . '', - '#attributes' => array('id' => 'simpletest-form-table'), ); // Define the images used to expand/collapse the test groups. + $image_collapsed = array( + '#theme' => 'image', + '#uri' => 'core/misc/menu-collapsed.png', + '#width' => '7', + '#height' => '7', + '#alt' => $this->t('Expand'), + '#title' => $this->t('Expand'), + '#suffix' => '(' . $this->t('Expand') . ')', + ); + $image_extended = array( + '#theme' => 'image', + '#uri' => 'core/misc/menu-expanded.png', + '#width' => '7', + '#height' => '7', + '#alt' => $this->t('Collapse'), + '#title' => $this->t('Collapse'), + '#suffix' => '(' . $this->t('Collapse') . ')', + ); $js = array( 'images' => array( - theme('image', array( - 'uri' => 'core/misc/menu-collapsed.png', - 'width' => 7, - 'height' => 7, - 'alt' => t('Expand'), - 'title' => t('Expand'), - )) . ' (' . t('Expand') . ')', - theme('image', array( - 'uri' => 'core/misc/menu-expanded.png', - 'width' => 7, - 'height' => 7, - 'alt' => t('Collapse'), - 'title' => t('Collapse'), - )) . ' (' . t('Collapse') . ')', + drupal_render($image_collapsed), + drupal_render($image_extended), ), ); - // Cycle through each test group and create a row. - $rows = array(); - // Generate the list of tests arranged by group. $groups = simpletest_test_get_all(); $groups['PHPUnit'] = simpletest_phpunit_get_available_tests(); @@ -93,31 +100,29 @@ foreach ($groups as $group => $tests) { $form['tests']['table'][$group] = array( - '#collapsed' => TRUE, '#attributes' => array('class' => array('simpletest-group')), ); // Make the class name safe for output on the page by replacing all // non-word/decimal characters with a dash (-). - $test_class = strtolower(trim(preg_replace("/[^\w\d]/", "-", $group))); + $group_class = 'module-' . strtolower(trim(preg_replace("/[^\w\d]/", "-", $group))); - // Place-holder for checkboxes to select group of tests. - $form['tests']['table'][$group]['checkbox'] = array( + // Override tableselect column with custom selector for this group. + $form['tests']['table'][$group]['select'] = array( '#wrapper_attributes' => array( - 'id' => $test_class, + 'id' => $group_class, 'class' => array('simpletest-select-all'), ), ); // Expand/collapse image and group title. $form['tests']['table'][$group]['title'] = array( - '#markup' => '
' . - '', + '#prefix' => '', + '#markup' => '', '#wrapper_attributes' => array( 'class' => array('simpletest-group-label'), ), ); - $form['tests']['table'][$group]['description'] = array( '#markup' => ' ', '#wrapper_attributes' => array( @@ -127,65 +132,60 @@ // Add individual tests to group. $current_js = array( - 'testClass' => $test_class . '-test', + 'testClass' => $group_class . '-test', 'testNames' => array(), // imageDirection maps to the 'images' index in the $js array. 'imageDirection' => 0, 'clickActive' => FALSE, ); - // Sorting $element by children's name attribute instead of by class name. - uasort($tests, array($this, 'elementSortByName')); + // Sort test classes within group alphabetically by name/label. + uasort($tests, function ($a, $b) { + return SortArray::sortByKeyString($a, $b, 'name'); + }); // Cycle through each test within the current group. foreach ($tests as $class => $info) { - $test_class_id = 'edit-' . drupal_html_id($class); - $current_js['testNames'][] = $test_class_id; - - $form['tests']['table'][$test_class_id] = array( - '#attributes' => array('class' => array($test_class . '-test', 'js-hide')), - ); + $test_id = drupal_clean_id_identifier($class); + $test_checkbox_id = 'edit-' . $test_id . '-select'; + $current_js['testNames'][] = $test_checkbox_id; - $form['tests']['table'][$test_class_id]['checkbox'] = array( - '#wrapper_attributes' => array( - 'class' => array('simpletest-test-select'), - ), - 'checkbox' => array( - '#type' => 'checkbox', - '#title_display' => 'invisible', - '#title' => $info['name'], - '#attributes' => array( - 'aria-describedby' => $test_class_id . '--description', - ), - '#parents' => array($class), - ), + $form['tests']['table'][$test_id] = array( + '#attributes' => array('class' => array($group_class . '-test', 'js-hide')), ); - - $form['tests']['table'][$test_class_id]['title'] = array( - '#markup' => '', + $form['tests']['table'][$test_id]['title'] = array( + '#prefix' => '', '#wrapper_attributes' => array( - 'class' => array('simpletest-test-label'), + 'class' => array('simpletest-test-label', 'table-filter-text-source'), ), ); - - $form['tests']['table'][$test_class_id]['description'] = array( - '#markup' => '