Skip to content
Snippets Groups Projects
Unverified Commit 42e71505 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2945247 by Mile23: Remove usages of @deprecated simpletest functions

parent 54cd2b25
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -403,7 +403,7 @@ function simpletest_phpunit_command() { ...@@ -403,7 +403,7 @@ function simpletest_phpunit_command() {
* Implements callback_batch_operation(). * Implements callback_batch_operation().
*/ */
function _simpletest_batch_operation($test_list_init, $test_id, &$context) { function _simpletest_batch_operation($test_list_init, $test_id, &$context) {
simpletest_classloader_register(); \Drupal::service('test_discovery')->registerTestNamespaces();
// Get working values. // Get working values.
if (!isset($context['sandbox']['max'])) { if (!isset($context['sandbox']['max'])) {
// First iteration: initialize working values. // First iteration: initialize working values.
...@@ -587,6 +587,7 @@ function simpletest_log_read($test_id, $database_prefix, $test_class) { ...@@ -587,6 +587,7 @@ function simpletest_log_read($test_id, $database_prefix, $test_class) {
* instead. * instead.
*/ */
function simpletest_test_get_all($extension = NULL, array $types = []) { 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); return \Drupal::service('test_discovery')->getTestClasses($extension, $types);
} }
...@@ -597,6 +598,7 @@ function simpletest_test_get_all($extension = NULL, array $types = []) { ...@@ -597,6 +598,7 @@ function simpletest_test_get_all($extension = NULL, array $types = []) {
* \Drupal::service('test_discovery')->registerTestNamespaces() instead. * \Drupal::service('test_discovery')->registerTestNamespaces() instead.
*/ */
function simpletest_classloader_register() { 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(); \Drupal::service('test_discovery')->registerTestNamespaces();
} }
......
<?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();
}
}
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
echo "\nAvailable test groups & classes\n"; echo "\nAvailable test groups & classes\n";
echo "-------------------------------\n\n"; echo "-------------------------------\n\n";
try { try {
$groups = simpletest_test_get_all($args['module']); $groups = \Drupal::service('test_discovery')->getTestClasses($args['module']);
} }
catch (Exception $e) { catch (Exception $e) {
error_log((string) $e); error_log((string) $e);
...@@ -1004,11 +1004,13 @@ function simpletest_script_cleanup($test_id, $test_class, $exitcode) { ...@@ -1004,11 +1004,13 @@ function simpletest_script_cleanup($test_id, $test_class, $exitcode) {
function simpletest_script_get_test_list() { function simpletest_script_get_test_list() {
global $args; global $args;
/** $test_discovery \Drupal\simpletest\TestDiscovery */
$test_discovery = \Drupal::service('test_discovery');
$types_processed = empty($args['types']); $types_processed = empty($args['types']);
$test_list = []; $test_list = [];
if ($args['all'] || $args['module']) { if ($args['all'] || $args['module']) {
try { try {
$groups = simpletest_test_get_all($args['module'], $args['types']); $groups = $test_discovery->getTestClasses($args['module'], $args['types']);
$types_processed = TRUE; $types_processed = TRUE;
} }
catch (Exception $e) { catch (Exception $e) {
...@@ -1031,7 +1033,7 @@ function simpletest_script_get_test_list() { ...@@ -1031,7 +1033,7 @@ function simpletest_script_get_test_list() {
} }
else { else {
try { try {
$groups = simpletest_test_get_all(NULL, $args['types']); $groups = $test_discovery->getTestClasses(NULL, $args['types']);
} }
catch (Exception $e) { catch (Exception $e) {
echo (string) $e; echo (string) $e;
...@@ -1132,7 +1134,7 @@ function simpletest_script_get_test_list() { ...@@ -1132,7 +1134,7 @@ function simpletest_script_get_test_list() {
} }
else { else {
try { try {
$groups = simpletest_test_get_all(NULL, $args['types']); $groups = $test_discovery->getTestClasses(NULL, $args['types']);
$types_processed = TRUE; $types_processed = TRUE;
} }
catch (Exception $e) { catch (Exception $e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment