Issue #2945247 by Mile23: Remove usages of @deprecated simpletest functions
parent
54cd2b2569
commit
42e71505f5
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue