diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index 6670e5acc0b..dd05ddc1ca7 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -403,7 +403,7 @@ function simpletest_phpunit_command() { * Implements callback_batch_operation(). */ function _simpletest_batch_operation($test_list_init, $test_id, &$context) { - simpletest_classloader_register(); + \Drupal::service('test_discovery')->registerTestNamespaces(); // Get working values. if (!isset($context['sandbox']['max'])) { // First iteration: initialize working values. @@ -587,6 +587,7 @@ function simpletest_log_read($test_id, $database_prefix, $test_class) { * instead. */ function simpletest_test_get_all($extension = NULL, array $types = []) { + @trigger_error('The ' . __FUNCTION__ . ' function is deprecated in version 8.3.x and will be removed in 9.0.0. Use \Drupal::service(\'test_discovery\')->getTestClasses($extension, $types) instead.', E_USER_DEPRECATED); return \Drupal::service('test_discovery')->getTestClasses($extension, $types); } @@ -597,6 +598,7 @@ function simpletest_test_get_all($extension = NULL, array $types = []) { * \Drupal::service('test_discovery')->registerTestNamespaces() instead. */ function simpletest_classloader_register() { + @trigger_error('The ' . __FUNCTION__ . ' function is deprecated in version 8.3.x and will be removed in 9.0.0. Use \Drupal::service(\'test_discovery\')->registerTestNamespaces() instead.', E_USER_DEPRECATED); \Drupal::service('test_discovery')->registerTestNamespaces(); } diff --git a/core/modules/simpletest/tests/src/Kernel/SimpletestDeprecationTest.php b/core/modules/simpletest/tests/src/Kernel/SimpletestDeprecationTest.php new file mode 100644 index 00000000000..384f8c1b9b3 --- /dev/null +++ b/core/modules/simpletest/tests/src/Kernel/SimpletestDeprecationTest.php @@ -0,0 +1,28 @@ +getTestClasses($extension, $types) instead. + * @expectedDeprecation The simpletest_classloader_register function is deprecated in version 8.3.x and will be removed in 9.0.0. Use \Drupal::service('test_discovery')->registerTestNamespaces() instead. + */ + public function testDeprecatedFunctions() { + $this->assertNotEmpty(simpletest_phpunit_configuration_filepath()); + $this->assertNotEmpty(simpletest_test_get_all()); + simpletest_classloader_register(); + } + +} diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index e1ef7db7371..eb77e135f32 100644 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -64,7 +64,7 @@ if ($args['list']) { echo "\nAvailable test groups & classes\n"; echo "-------------------------------\n\n"; try { - $groups = simpletest_test_get_all($args['module']); + $groups = \Drupal::service('test_discovery')->getTestClasses($args['module']); } catch (Exception $e) { error_log((string) $e); @@ -1004,11 +1004,13 @@ function simpletest_script_cleanup($test_id, $test_class, $exitcode) { function simpletest_script_get_test_list() { global $args; + /** $test_discovery \Drupal\simpletest\TestDiscovery */ + $test_discovery = \Drupal::service('test_discovery'); $types_processed = empty($args['types']); $test_list = []; if ($args['all'] || $args['module']) { try { - $groups = simpletest_test_get_all($args['module'], $args['types']); + $groups = $test_discovery->getTestClasses($args['module'], $args['types']); $types_processed = TRUE; } catch (Exception $e) { @@ -1031,7 +1033,7 @@ function simpletest_script_get_test_list() { } else { try { - $groups = simpletest_test_get_all(NULL, $args['types']); + $groups = $test_discovery->getTestClasses(NULL, $args['types']); } catch (Exception $e) { echo (string) $e; @@ -1132,7 +1134,7 @@ function simpletest_script_get_test_list() { } else { try { - $groups = simpletest_test_get_all(NULL, $args['types']); + $groups = $test_discovery->getTestClasses(NULL, $args['types']); $types_processed = TRUE; } catch (Exception $e) {