public function PHPUnit_Framework_TestSuite::__construct

Constructs a new TestSuite:

  • PHPUnit_Framework_TestSuite() constructs an empty TestSuite.
  • PHPUnit_Framework_TestSuite(ReflectionClass) constructs a TestSuite from the given class.
  • PHPUnit_Framework_TestSuite(ReflectionClass, String) constructs a TestSuite from the given class with the given name.
  • PHPUnit_Framework_TestSuite(String) either constructs a TestSuite from the given class (if the passed string is the name of an existing class) or constructs an empty TestSuite with the given name.

Parameters

mixed $theClass:

string $name:

Throws

PHPUnit_Framework_Exception

2 methods override PHPUnit_Framework_TestSuite::__construct()
PHPUnit_Extensions_GroupTestSuite::__construct in drupal/core/vendor/phpunit/phpunit/PHPUnit/Extensions/GroupTestSuite.php
Constructs a new TestSuite:
PHPUnit_Extensions_PhptTestSuite::__construct in drupal/core/vendor/phpunit/phpunit/PHPUnit/Extensions/PhptTestSuite.php
Constructs a new TestSuite for .phpt test cases.

File

drupal/core/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php, line 152

Class

PHPUnit_Framework_TestSuite
A TestSuite is a composite of Tests. It runs a collection of test cases.

Code

public function __construct($theClass = '', $name = '') {
  $argumentsValid = FALSE;
  if (is_object($theClass) && $theClass instanceof ReflectionClass) {
    $argumentsValid = TRUE;
  }
  else {
    if (is_string($theClass) && $theClass !== '' && class_exists($theClass, FALSE)) {
      $argumentsValid = TRUE;
      if ($name == '') {
        $name = $theClass;
      }
      $theClass = new ReflectionClass($theClass);
    }
    else {
      if (is_string($theClass)) {
        $this
          ->setName($theClass);
        return;
      }
    }
  }
  if (!$argumentsValid) {
    throw new PHPUnit_Framework_Exception();
  }
  if (!$theClass
    ->isSubclassOf('PHPUnit_Framework_TestCase')) {
    throw new PHPUnit_Framework_Exception('Class "' . $theClass->name . '" does not extend PHPUnit_Framework_TestCase.');
  }
  if ($name != '') {
    $this
      ->setName($name);
  }
  else {
    $this
      ->setName($theClass
      ->getName());
  }
  $constructor = $theClass
    ->getConstructor();
  if ($constructor !== NULL && !$constructor
    ->isPublic()) {
    $this
      ->addTest(self::warning(sprintf('Class "%s" has no public constructor.', $theClass
      ->getName())));
    return;
  }
  foreach ($theClass
    ->getMethods() as $method) {
    $this
      ->addTestMethod($theClass, $method);
  }
  if (empty($this->tests)) {
    $this
      ->addTest(self::warning(sprintf('No tests found in class "%s".', $theClass
      ->getName())));
  }
  $this->testCase = TRUE;
}