function 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
1 call to EnvironmentCleaner::cleanResultsTable()
- 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 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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.