You are here

function simpletest_run_tests in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/simpletest.module \simpletest_run_tests()

Runs tests.

Parameters

$test_list: List of tests to run.

Return value

string The test ID.

1 call to simpletest_run_tests()
SimpletestTestForm::submitForm in core/modules/simpletest/src/Form/SimpletestTestForm.php
Form submission handler.

File

core/modules/simpletest/simpletest.module, line 123
Provides testing functionality.

Code

function simpletest_run_tests($test_list) {
  $test_id = db_insert('simpletest_test_id')
    ->useDefaults(array(
    'test_id',
  ))
    ->execute();
  if (!empty($test_list['phpunit'])) {
    $phpunit_results = simpletest_run_phpunit_tests($test_id, $test_list['phpunit']);
    simpletest_process_phpunit_results($phpunit_results);
  }

  // Early return if there are no further tests to run.
  if (empty($test_list['simpletest'])) {
    return $test_id;
  }

  // Continue with SimpleTests only.
  $test_list = $test_list['simpletest'];

  // Clear out the previous verbose files.
  file_unmanaged_delete_recursive('public://simpletest/verbose');

  // Get the info for the first test being run.
  $first_test = reset($test_list);
  $info = TestDiscovery::getTestInfo($first_test);
  $batch = array(
    'title' => t('Running tests'),
    'operations' => array(
      array(
        '_simpletest_batch_operation',
        array(
          $test_list,
          $test_id,
        ),
      ),
    ),
    'finished' => '_simpletest_batch_finished',
    'progress_message' => '',
    'library' => array(
      'simpletest/drupal.simpletest',
    ),
    'init_message' => t('Processing test @num of @max - %test.', array(
      '%test' => $info['name'],
      '@num' => '1',
      '@max' => count($test_list),
    )),
  );
  batch_set($batch);
  \Drupal::moduleHandler()
    ->invokeAll('test_group_started');
  return $test_id;
}