function simpletest_clean_results_table in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/simpletest/simpletest.module \simpletest_clean_results_table()
Clears the test result tables.
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.
2 calls to simpletest_clean_results_table()
- SimpletestResultsForm::buildForm in core/modules/ simpletest/ src/ Form/ SimpletestResultsForm.php 
- Form constructor.
- simpletest_clean_environment in core/modules/ simpletest/ simpletest.module 
- Removes all temporary database tables and directories.
File
- core/modules/ simpletest/ simpletest.module, line 644 
- Provides testing functionality.
Code
function simpletest_clean_results_table($test_id = NULL) {
  if (\Drupal::config('simpletest.settings')
    ->get('clear_results')) {
    $connection = TestBase::getDatabaseConnection();
    if ($test_id) {
      $count = $connection
        ->query('SELECT COUNT(test_id) FROM {simpletest_test_id} WHERE test_id = :test_id', array(
        ':test_id' => $test_id,
      ))
        ->fetchField();
      $connection
        ->delete('simpletest')
        ->condition('test_id', $test_id)
        ->execute();
      $connection
        ->delete('simpletest_test_id')
        ->condition('test_id', $test_id)
        ->execute();
    }
    else {
      $count = $connection
        ->query('SELECT COUNT(test_id) FROM {simpletest_test_id}')
        ->fetchField();
      // Clear test results.
      $connection
        ->delete('simpletest')
        ->execute();
      $connection
        ->delete('simpletest_test_id')
        ->execute();
    }
    return $count;
  }
  return 0;
}