diff --git a/core/lib/Drupal/Core/Test/EnvironmentCleaner.php b/core/lib/Drupal/Core/Test/EnvironmentCleaner.php index 23976b666c..31da3cfc07 100644 --- a/core/lib/Drupal/Core/Test/EnvironmentCleaner.php +++ b/core/lib/Drupal/Core/Test/EnvironmentCleaner.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\OutputInterface; /** - * Clean up after tests. + * Helper class for cleaning test environments. */ class EnvironmentCleaner implements EnvironmentCleanerInterface { @@ -29,6 +29,8 @@ class EnvironmentCleaner implements EnvironmentCleanerInterface { * Connection to the database where test results are stored. * * This could be the same as $testDatabase, or it could be different. + * run-tests.sh allows you to specify a different results database with the + * --sqlite parameter. * * @var \Drupal\Core\Database\Connection */ @@ -42,6 +44,7 @@ class EnvironmentCleaner implements EnvironmentCleanerInterface { protected $fileSystem; /** + * Console output. * * @var \Symfony\Component\Console\Output\OutputInterface */ @@ -104,6 +107,7 @@ public function cleanDatabase() { } /** + * Performs the fixture database cleanup. * * @return int * The number of tables that were removed. @@ -138,6 +142,7 @@ public function cleanTemporaryDirectories() { } /** + * Performs the cleanup of temporary test directories. * * @return int * The count of temporary directories removed. diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index 947828f2ec..a2ee22a6b9 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -658,12 +658,13 @@ function simpletest_clean_temporary_directories() { */ function simpletest_clean_results_table($test_id = NULL) { @trigger_error(__FUNCTION__ . ' is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Access the environment_cleaner service and call its cleanResultsTable() method, or use \Drupal\Core\Test\EnvironmentCleaner::cleanResultsTable() instead. See https://www.drupal.org/node/3076634', E_USER_DEPRECATED); + $count = 0; if (\Drupal::config('simpletest.settings')->get('clear_results')) { /* @var $cleaner \Drupal\simpletest\EnvironmentCleanerService */ $cleaner = \Drupal::service('environment_cleaner'); - $cleaner->cleanResultsTable($test_id); + $count = $cleaner->cleanResultsTable($test_id); } - return 0; + return $count; } /** diff --git a/core/modules/simpletest/simpletest.services.yml b/core/modules/simpletest/simpletest.services.yml index cede4646b5..afae7c4358 100644 --- a/core/modules/simpletest/simpletest.services.yml +++ b/core/modules/simpletest/simpletest.services.yml @@ -1,17 +1,13 @@ services: test_discovery: - # Drupal\simpletest\TestDiscovery is deprecated, but we still want to use it - # as the service here to support BC hooks. class: Drupal\simpletest\TestDiscovery arguments: ['@app.root', '@class_loader', '@module_handler'] - environment_cleaner_factory: class: Drupal\simpletest\EnvironmentCleanerFactory arguments: ['@service_container'] environment_cleaner: class: Drupal\simpletest\EnvironmentCleanerService factory: 'environment_cleaner_factory:createCleaner' - cache_context.test_discovery: class: Drupal\simpletest\Cache\Context\TestDiscoveryCacheContext arguments: ['@test_discovery', '@private_key'] diff --git a/core/modules/simpletest/tests/src/Kernel/DeprecatedCleanupTest.php b/core/modules/simpletest/tests/src/Kernel/DeprecatedCleanupTest.php index a5efa34a1e..ec29a76768 100644 --- a/core/modules/simpletest/tests/src/Kernel/DeprecatedCleanupTest.php +++ b/core/modules/simpletest/tests/src/Kernel/DeprecatedCleanupTest.php @@ -36,7 +36,7 @@ public function testDeprecatedCleanFunctions() { $this->assertNull(simpletest_clean_environment()); $this->assertNull(simpletest_clean_database()); $this->assertNull(simpletest_clean_temporary_directories()); - $this->assertNull(simpletest_clean_results_table()); + $this->assertEquals(0, simpletest_clean_results_table()); } }