public function __construct($theClass = '', $name = '')
{
$argumentsValid = false;
if (is_object($theClass) && $theClass instanceof ReflectionClass) {
$argumentsValid = true;
} elseif (is_string($theClass) && $theClass !== '' && class_exists($theClass, false)) {
$argumentsValid = true;
if ($name == '') {
$name = $theClass;
}
$theClass = new ReflectionClass($theClass);
} elseif (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;
}