simpletest_run_tests

Versions
7
simpletest_run_tests($test_list, $reporter = 'drupal')

Actually runs tests.

Parameters

$test_list List of tests to run.

$reporter Which reporter to use. Allowed values are: text, xml, html and drupal, drupal being the default.

Code

modules/simpletest/simpletest.module, line 138

<?php
function simpletest_run_tests($test_list, $reporter = 'drupal') {
  cache_clear_all();
  $test_id = db_insert('simpletest_test_id')
    ->useDefaults(array('test_id'))
    ->execute();

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

  // Get the info for the first test being run.
  $first_test = array_shift($test_list);
  $first_instance = new $first_test();
  array_unshift($test_list, $first_test);
  $info = $first_instance->getInfo();

  $batch = array(
    'title' => t('Running tests'),
    'operations' => array(
      array('_simpletest_batch_operation', array($test_list, $test_id)),
    ),
    'finished' => '_simpletest_batch_finished',
    'progress_message' => '',
    'css' => array(drupal_get_path('module', 'simpletest') . '/simpletest.css'),
    'init_message' => t('Processing test @num of @max - %test.', array('%test' => $info['name'], '@num' => '1', '@max' => count($test_list))),
  );
  batch_set($batch);

  module_invoke_all('test_group_started');

  // Normally, the forms portion of the batch API takes care of calling
  // batch_process(), but in the process it saves the whole $form into the
  // database (which is huge for the test selection form).
  // By calling batch_process() directly, we skip that behavior and ensure
  // that we don't exceed the size of data that can be sent to the database
  // (max_allowed_packet on MySQL).
  batch_process('admin/config/development/testing/results/' . $test_id);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.