PHPUnit_Framework_TestSuite::addTestSuite PHP Method

addTestSuite() public method

Adds the tests from the given class to the suite.
public addTestSuite ( mixed $testClass )
$testClass mixed
    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();
        }
    }

Usage Example

Example #1
0
 public static function suite()
 {
     $suite = new PHPUnit_Framework_TestSuite('PHPUnit_Framework');
     $suite->addTestSuite('RightWayToUseObjectUtil');
     $suite->addTestSuite('WrongWayToUseObjectUtil');
     return $suite;
 }
All Usage Examples Of PHPUnit_Framework_TestSuite::addTestSuite