class EnvironmentCleanerService extends EnvironmentCleaner (View source)

Uses containerized services to perform post-test cleanup.

Properties

protected string $root

Path to Drupal root directory.

from  EnvironmentCleaner
protected Connection $testDatabase

Connection to the database being used for tests.

from  EnvironmentCleaner
protected Connection $resultsDatabase

Connection to the database where test results are stored.

from  EnvironmentCleaner
protected FileSystemInterface $fileSystem

The file system service.

from  EnvironmentCleaner
protected OutputInterface $output

Console output.

from  EnvironmentCleaner
protected MessengerInterface $messenger

Messenger service.

protected TranslationInterface $translation

The translation service.

protected ConfigFactory $configFactory

The config factory.

protected CacheBackendInterface $cacheDefault

Default cache.

Methods

__construct(string $root, Connection $test_database, Connection $results_database, MessengerInterface $messenger, TranslationInterface $translation, ConfigFactory $config, CacheBackendInterface $cache_default, FileSystemInterface $file_system)

Construct an environment cleaner.

cleanEnvironment(bool $clear_results = TRUE, bool $clear_temp_directories = TRUE, bool $clear_database = TRUE)

Removes all test-related database tables and directories.

cleanDatabase()

Remove database entries left over in the fixture database.

int
doCleanDatabase()

Performs the fixture database cleanup.

cleanTemporaryDirectories()

Finds all leftover fixture site directories and removes them.

int
doCleanTemporaryDirectories()

Performs the cleanup of temporary test directories.

int
cleanResultsTable($test_id = NULL)

Clears test result tables from the results database.

Details

__construct(string $root, Connection $test_database, Connection $results_database, MessengerInterface $messenger, TranslationInterface $translation, ConfigFactory $config, CacheBackendInterface $cache_default, FileSystemInterface $file_system)

Construct an environment cleaner.

Parameters

string $root

The path to the root of the Drupal installation.

Connection $test_database

Connection to the database against which tests were run.

Connection $results_database

Connection to the database where test results were stored. This could be the same as $test_database, or it could be different.

MessengerInterface $messenger
TranslationInterface $translation

(optional) The translation service. If none is supplied, this class will attempt to discover one using \Drupal.

ConfigFactory $config
CacheBackendInterface $cache_default
FileSystemInterface $file_system

The file_system service.

cleanEnvironment(bool $clear_results = TRUE, bool $clear_temp_directories = TRUE, bool $clear_database = TRUE)

Removes all test-related database tables and directories.

This method removes fixture files and database entries from the system under test.

Parameters

bool $clear_results

(optional) Whether to clear the test results database. Defaults to TRUE.

bool $clear_temp_directories

(optional) Whether to clear the test site directories. Defaults to TRUE.

bool $clear_database

(optional) Whether to clean up the fixture database. Defaults to TRUE.

cleanDatabase()

Remove database entries left over in the fixture database.

protected int doCleanDatabase()

Performs the fixture database cleanup.

Return Value

int

The number of tables that were removed.

cleanTemporaryDirectories()

Finds all leftover fixture site directories and removes them.

protected int doCleanTemporaryDirectories()

Performs the cleanup of temporary test directories.

Return Value

int

The count of temporary directories removed.

int cleanResultsTable($test_id = NULL)

Clears test result tables from the results database.

Parameters

$test_id

Test ID to remove results for, or NULL to remove all results.

Return Value

int

The number of results that were removed.