function EnvironmentCleaner::doCleanDatabase
Same name in other branches
- 9 core/lib/Drupal/Core/Test/EnvironmentCleaner.php \Drupal\Core\Test\EnvironmentCleaner::doCleanDatabase()
- 8.9.x core/lib/Drupal/Core/Test/EnvironmentCleaner.php \Drupal\Core\Test\EnvironmentCleaner::doCleanDatabase()
- 10 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 78
Class
- EnvironmentCleaner
- Helper class for cleaning test environments.
Namespace
Drupal\Core\TestCode
protected function doCleanDatabase() : int {
/** @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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.