diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index 6670e5acc0be04963f33bdf3bcbc48ee63b9e678..dd05ddc1ca718a630d9f87b36a6f1ca5b23e9388 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 0000000000000000000000000000000000000000..384f8c1b9b36a79d04a379dc05a5303a4edc0255 --- /dev/null +++ b/core/modules/simpletest/tests/src/Kernel/SimpletestDeprecationTest.php @@ -0,0 +1,28 @@ +<?php + +namespace Drupal\Tests\simpletest\Kernel; + +use Drupal\KernelTests\KernelTestBase; + +/** + * Verify deprecation of simpletest. + * + * @group simpletest + * @group legacy + */ +class SimpletestDeprecationTest extends KernelTestBase { + + public static $modules = ['simpletest']; + + /** + * @expectedDeprecation The simpletest_phpunit_configuration_filepath function is deprecated since version 8.4.x and will be removed in 9.0.0. + * @expectedDeprecation The simpletest_test_get_all 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. + * @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 e1ef7db737110e91e4c7ec94c616e776517dc07b..eb77e135f325b64b184bc5e9595966a3b88dd6fb 100644 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -64,7 +64,7 @@ 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) {