You are here

public function Framework::selfTest in Realistic Dummy Content 7.2

Same name and namespace in other branches
  1. 8.2 api/src/Framework/Framework.php \Drupal\realistic_dummy_content_api\Framework\Framework::selfTest()
  2. 3.x api/src/Framework/Framework.php \Drupal\realistic_dummy_content_api\Framework\Framework::selfTest()

Tests all functions in the class.

File

api/src/Framework/Framework.php, line 380

Class

Framework
The entry point for the framework.

Namespace

Drupal\realistic_dummy_content_api\Framework

Code

public function selfTest() {
  $all = get_class_methods(get_class($this));
  $errors = array();
  $tests = array();
  foreach ($all as $method_name) {
    if (substr($method_name, 0, strlen('test')) == 'test') {
      continue;
    }
    $candidate = 'test' . ucfirst($method_name);
    if (in_array($candidate, $all)) {
      try {
        $result = $this
          ->{$candidate}();
        if ($result) {
          $errors[] = $candidate . ' test failed.';
        }
        else {
          $tests[] = $candidate . ' test passed.';
        }
      } catch (\Exception $e) {
        $errors[] = $candidate . ' threw an exception: ' . $e
          ->getMessage();
      }
    }
  }
  $this
    ->frameworkSpecificTests($errors, $tests);
  $this
    ->endToEndTests($errors, $tests);
  self::debug('Errors:');
  self::debug($errors);
  self::debug('Passed tests:');
  self::debug($tests);
  return count($errors) != 0;
}