diff --git a/core/modules/simpletest/src/Form/SimpletestTestForm.php b/core/modules/simpletest/src/Form/SimpletestTestForm.php index 488a093..ae185f1 100644 --- a/core/modules/simpletest/src/Form/SimpletestTestForm.php +++ b/core/modules/simpletest/src/Form/SimpletestTestForm.php @@ -6,6 +6,7 @@ use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\RendererInterface; +use Drupal\simpletest\TestDiscovery; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -31,11 +32,19 @@ class SimpletestTestForm extends FormBase { protected $appRoot; /** + * The test discovery service. + * + * @var \Drupal\simpletest\TestDiscovery + */ + protected $testDiscovery; + + /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('renderer'), + $container->get('test_discovery'), (string) $container->get('app.root') ); } @@ -48,8 +57,9 @@ public static function create(ContainerInterface $container) { * @param \Drupal\simpletest\TestDiscovery $test_discovery * The test discovery service. */ - public function __construct(RendererInterface $renderer, $app_root) { + public function __construct(RendererInterface $renderer, TestDiscovery $test_discovery, $app_root) { $this->renderer = $renderer; + $this->testDiscovery = $test_discovery; $this->appRoot = $app_root; } @@ -158,11 +168,11 @@ public function buildForm(array $form, FormStateInterface $form_state) { $extension_names[$type] = array_keys($extension_discovery->scan($type, TRUE)); } // Generate the list of tests arranged by group. - $groups = simpletest_test_get_all(); + $groups = $this->testDiscovery->getTestClasses(); foreach ($groups as $group => $tests) { // Add the extension type to group names which are also extension names. foreach ($extension_types as $type) { - if (in_array($group, $extension_names[$type])) { + if (in_array($group, $extension_names[$type], TRUE)) { $group = $group . ' ' . $type; } } @@ -229,7 +239,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. - simpletest_classloader_register(); + $this->testDiscovery->registerTestNamespaces(); // This form accepts arbitrary user input for 'tests'. // An invalid value will cause the $class_name lookup below to die with a