protected function EnvironmentCleaner::doCleanDatabase in Drupal 8
Same name and namespace in other branches
- 9 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.
3 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.
- EnvironmentCleanerService::cleanDatabase in core/
modules/ simpletest/ src/ EnvironmentCleanerService.php - Remove database entries left over in the fixture database.
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 $schema \Drupal\Core\Database\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;
}