You are here

function simpletest_clean_results_table in SimpleTest 7

Same name and namespace in other branches
  1. 8.3 simpletest.module \simpletest_clean_results_table()
  2. 6.2 simpletest.module \simpletest_clean_results_table()
  3. 7.2 simpletest.module \simpletest_clean_results_table()

Clear the test result tables.

Parameters

$test_id: Test ID to remove results for, or NULL to remove all results.

Return value

The number of results removed.

2 calls to simpletest_clean_results_table()
simpletest_clean_environment in ./simpletest.module
Remove all temporary database tables and directories.
simpletest_result_form in ./simpletest.pages.inc
Test results form for $test_id.

File

./simpletest.module, line 468
Provides testing functionality.

Code

function simpletest_clean_results_table($test_id = NULL) {
  if (variable_get('simpletest_clear_results', TRUE)) {
    if ($test_id) {
      $count = db_query('SELECT COUNT(test_id) FROM {simpletest_test_id} WHERE test_id = :test_id', array(
        ':test_id' => $test_id,
      ))
        ->fetchField();
      db_delete('simpletest')
        ->condition('test_id', $test_id)
        ->execute();
      db_delete('simpletest_test_id')
        ->condition('test_id', $test_id)
        ->execute();
    }
    else {
      $count = db_query('SELECT COUNT(test_id) FROM {simpletest_test_id}')
        ->fetchField();

      // Clear test results.
      db_delete('simpletest')
        ->execute();
      db_delete('simpletest_test_id')
        ->execute();
    }
    return $count;
  }
  return 0;
}