You are here

public function DrupalTestCase::run in SimpleTest 7

Same name and namespace in other branches
  1. 5 drupal_test_case.php \DrupalTestCase::run()
  2. 6.2 drupal_web_test_case.php \DrupalTestCase::run()
  3. 6 drupal_test_case.php \DrupalTestCase::run()
  4. 7.2 drupal_web_test_case.php \DrupalTestCase::run()

Run all tests in this class.

File

./drupal_web_test_case.php, line 391

Class

DrupalTestCase
Base class for Drupal tests.

Code

public function run() {

  // Initialize verbose debugging.
  simpletest_verbose(NULL, file_directory_path(), get_class($this));

  // HTTP auth settings (<username>:<password>) for the simpletest browser
  // when sending requests to the test site.
  $username = variable_get('simpletest_username', NULL);
  $password = variable_get('simpletest_password', NULL);
  if ($username && $password) {
    $this->httpauth_credentials = $username . ':' . $password;
  }
  set_error_handler(array(
    $this,
    'errorHandler',
  ));
  $methods = array();

  // Iterate through all the methods in this class.
  foreach (get_class_methods(get_class($this)) as $method) {

    // If the current method starts with "test", run it - it's a test.
    if (strtolower(substr($method, 0, 4)) == 'test') {
      $this
        ->setUp();
      try {
        $this
          ->{$method}();

        // Finish up.
      } catch (Exception $e) {
        $this
          ->exceptionHandler($e);
      }
      $this
        ->tearDown();
    }
  }

  // Clear out the error messages and restore error handler.
  drupal_get_messages();
  restore_error_handler();
}