protected function EnvironmentCleaner::doCleanDatabase in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Test/EnvironmentCleaner.php \Drupal\Core\Test\EnvironmentCleaner::doCleanDatabase()
Performs the fixture database cleanup.
Return value
int The number of tables that were removed.
2 calls to EnvironmentCleaner::doCleanDatabase()
- EnvironmentCleaner::cleanDatabase in core/
lib/ Drupal/ Core/ Test/ EnvironmentCleaner.php - Remove database entries left over in the fixture database.
- EnvironmentCleaner::cleanEnvironment in core/
lib/ Drupal/ Core/ Test/ EnvironmentCleaner.php - Removes all test-related database tables and directories.
File
- core/
lib/ Drupal/ Core/ Test/ EnvironmentCleaner.php, line 115
Class
- EnvironmentCleaner
- Helper class for cleaning test environments.
Namespace
Drupal\Core\TestCode
protected function doCleanDatabase() {
/** @var \Drupal\Core\Database\Schema $schema */
$schema = $this->testDatabase
->schema();
$tables = $schema
->findTables('test%');
$count = 0;
foreach ($tables as $table) {
// Only drop tables which begin wih 'test' followed by digits, for example,
// {test12345678node__body}.
if (preg_match('/^test\\d+.*/', $table, $matches)) {
$schema
->dropTable($matches[0]);
$count++;
}
}
return $count;
}