public function PHPUnit_Extensions_GroupTestSuite::__construct in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/phpunit/phpunit/src/Extensions/GroupTestSuite.php \PHPUnit_Extensions_GroupTestSuite::__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
Overrides PHPUnit_Framework_TestSuite::__construct
File
- vendor/
phpunit/ phpunit/ src/ Extensions/ GroupTestSuite.php, line 27
Class
- PHPUnit_Extensions_GroupTestSuite
- We have a TestSuite object A. In TestSuite object A we have Tests tagged with @group. We want a TestSuite object B that contains TestSuite objects C, D, ... for the Tests tagged with @group C, @group D, ... Running the Tests from TestSuite object B…
Code
public function __construct(PHPUnit_Framework_TestSuite $suite, array $groups) {
$groupSuites = array();
$name = $suite
->getName();
foreach ($groups as $group) {
$groupSuites[$group] = new PHPUnit_Framework_TestSuite($name . ' - ' . $group);
$this
->addTest($groupSuites[$group]);
}
$tests = new RecursiveIteratorIterator(new PHPUnit_Util_TestSuiteIterator($suite), RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($tests as $test) {
if ($test instanceof PHPUnit_Framework_TestCase) {
$testGroups = PHPUnit_Util_Test::getGroups(get_class($test), $test
->getName(false));
foreach ($groups as $group) {
foreach ($testGroups as $testGroup) {
if ($group == $testGroup) {
$groupSuites[$group]
->addTest($test);
}
}
}
}
}
}