diff --git a/core/modules/simpletest/src/Form/SimpletestTestForm.php b/core/modules/simpletest/src/Form/SimpletestTestForm.php index ec99784..3cac3f4 100644 --- a/core/modules/simpletest/src/Form/SimpletestTestForm.php +++ b/core/modules/simpletest/src/Form/SimpletestTestForm.php @@ -2,10 +2,10 @@ namespace Drupal\simpletest\Form; +use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\RendererInterface; -use Drupal\simpletest\TestDiscovery; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -21,11 +21,14 @@ class SimpletestTestForm extends FormBase { protected $renderer; /** - * The test discovery service. + * Path to the application root. * - * @var \Drupal\simpletest\TestDiscovery + * We need this so that we can do discovery of extensions, and show the user + * which tests belong with which extension. + * + * @var string */ - protected $testDiscovery; + protected $appRoot; /** * {@inheritdoc} @@ -33,7 +36,7 @@ class SimpletestTestForm extends FormBase { public static function create(ContainerInterface $container) { return new static( $container->get('renderer'), - $container->get('test_discovery') + (string) $container->get('app.root') ); } @@ -43,9 +46,9 @@ public static function create(ContainerInterface $container) { * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer. */ - public function __construct(RendererInterface $renderer, TestDiscovery $test_discovery) { + public function __construct(RendererInterface $renderer, $app_root) { $this->renderer = $renderer; - $this->testDiscovery = $test_discovery; + $this->appRoot = $app_root; } /** @@ -145,14 +148,21 @@ public function buildForm(array $form, FormStateInterface $form_state) { (string) $this->renderer->renderPlain($image_extended), ]; + // Get a list of all available extension names. + $extension_discovery = new ExtensionDiscovery($this->appRoot); + $extension_names = []; + $extension_types = ['module', 'theme', 'profile', 'theme engine']; + foreach($extension_types as $type) { + $extension_names[$type] = array_keys($extension_discovery->scan($type, TRUE)); + } // Generate the list of tests arranged by group. - $groups = $this->testDiscovery->getTestClasses(); + $groups = simpletest_test_get_all(); foreach ($groups as $group => $tests) { - // The convention is that groups based on namespaces are capitalized, - // and groups based on module names are not. In order to provide clarity, - // we add 'module' to module group names. - if (strtolower($group) == $group) { - $group = $group . ' module'; + // Add the extension type to group names which are also extension names. + foreach ($extension_types as $type) { + if (in_array($group, $extension_names[$type])) { + $group = $group . ' ' . $type; + } } $form['tests'][$group] = array( @@ -217,7 +227,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { */ public function submitForm(array &$form, FormStateInterface $form_state) { // Test discovery does not run upon form submission. - $this->testDiscovery->registerTestNamespaces(); + simpletest_classloader_register(); // This form accepts arbitrary user input for 'tests'. // An invalid value will cause the $class_name lookup below to die with a