function simpletest_clean_database
7.x simpletest.module | simpletest_clean_database() |
Removed prefixed tables from the database that are left over from crashed tests.
2 calls to simpletest_clean_database()
- simpletest_clean_environment in drupal-7.x/
modules/ simpletest/ simpletest.module - Remove all temporary database tables and directories.
- simpletest_uninstall in drupal-7.x/
modules/ simpletest/ simpletest.install - Implements hook_uninstall().
File
- drupal-7.x/
modules/ simpletest/ simpletest.module, line 537 - Provides testing functionality.
Code
function simpletest_clean_database() {
$tables = db_find_tables(Database::getConnection()->prefixTables('{simpletest}') . '%');
$schema = drupal_get_schema_unprocessed('simpletest');
$count = 0;
foreach (array_diff_key($tables, $schema) as $table) {
// Strip the prefix and skip tables without digits following "simpletest",
// e.g. {simpletest_test_id}.
if (preg_match('/simpletest\d+.*/', $table, $matches)) {
db_drop_table($matches[0]);
$count++;
}
}
if ($count > 0) {
drupal_set_message(format_plural($count, 'Removed 1 leftover table.', 'Removed @count leftover tables.'));
}
else {
drupal_set_message(t('No leftover tables to remove.'));
}
}