public function EnvironmentCleaner::cleanResultsTable in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Test/EnvironmentCleaner.php \Drupal\Core\Test\EnvironmentCleaner::cleanResultsTable()
- 10 core/lib/Drupal/Core/Test/EnvironmentCleaner.php \Drupal\Core\Test\EnvironmentCleaner::cleanResultsTable()
Clears test result tables from the results database.
Parameters
$test_id: Test ID to remove results for, or NULL to remove all results.
Return value
int The number of results that were removed.
Overrides EnvironmentCleanerInterface::cleanResultsTable
2 calls to EnvironmentCleaner::cleanResultsTable()
- EnvironmentCleaner::cleanEnvironment in core/
lib/ Drupal/ Core/ Test/ EnvironmentCleaner.php - Removes all test-related database tables and directories.
- EnvironmentCleanerService::cleanEnvironment in core/
modules/ simpletest/ src/ EnvironmentCleanerService.php - Removes all test-related database tables and directories.
File
- core/
lib/ Drupal/ Core/ Test/ EnvironmentCleaner.php, line 171
Class
- EnvironmentCleaner
- Helper class for cleaning test environments.
Namespace
Drupal\Core\TestCode
public function cleanResultsTable($test_id = NULL) {
$count = 0;
if ($test_id) {
$count = $this->resultsDatabase
->query('SELECT COUNT(test_id) FROM {simpletest_test_id} WHERE test_id = :test_id', [
':test_id' => $test_id,
])
->fetchField();
$this->resultsDatabase
->delete('simpletest')
->condition('test_id', $test_id)
->execute();
$this->resultsDatabase
->delete('simpletest_test_id')
->condition('test_id', $test_id)
->execute();
}
else {
$count = $this->resultsDatabase
->query('SELECT COUNT(test_id) FROM {simpletest_test_id}')
->fetchField();
// Clear test results.
$this->resultsDatabase
->delete('simpletest')
->execute();
$this->resultsDatabase
->delete('simpletest_test_id')
->execute();
}
return $count;
}