You are here

public function PHPUnit_Framework_TestSuite::addTestSuite in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Framework/TestSuite.php \PHPUnit_Framework_TestSuite::addTestSuite()

Adds the tests from the given class to the suite.

Parameters

mixed $testClass:

Throws

PHPUnit_Framework_Exception

1 call to PHPUnit_Framework_TestSuite::addTestSuite()
PHPUnit_Framework_TestSuite::addTestFile in vendor/phpunit/phpunit/src/Framework/TestSuite.php
Wraps both <code>addTest()</code> and <code>addTestSuite</code> as well as the separate import statements for the user's convenience.

File

vendor/phpunit/phpunit/src/Framework/TestSuite.php, line 260

Class

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

Code

public function addTestSuite($testClass) {
  if (is_string($testClass) && class_exists($testClass)) {
    $testClass = new ReflectionClass($testClass);
  }
  if (!is_object($testClass)) {
    throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'class name or object');
  }
  if ($testClass instanceof self) {
    $this
      ->addTest($testClass);
  }
  elseif ($testClass instanceof ReflectionClass) {
    $suiteMethod = false;
    if (!$testClass
      ->isAbstract()) {
      if ($testClass
        ->hasMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME)) {
        $method = $testClass
          ->getMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME);
        if ($method
          ->isStatic()) {
          $this
            ->addTest($method
            ->invoke(null, $testClass
            ->getName()));
          $suiteMethod = true;
        }
      }
    }
    if (!$suiteMethod && !$testClass
      ->isAbstract()) {
      $this
        ->addTest(new self($testClass));
    }
  }
  else {
    throw new PHPUnit_Framework_Exception();
  }
}