function simpletest_clean_database in SimpleTest 7
Same name and namespace in other branches
- 8.3 simpletest.module \simpletest_clean_database()
- 6.2 simpletest.module \simpletest_clean_database()
- 6 simpletest.module \simpletest_clean_database()
- 7.2 simpletest.module \simpletest_clean_database()
Removed prefixed tables from the database that are left over from crashed tests.
1 call to simpletest_clean_database()
- simpletest_clean_environment in ./
simpletest.module - Remove all temporary database tables and directories.
File
- ./
simpletest.module, line 417 - 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.'));
}
}