public function groupsForTest(\PHPUnit_Framework_Test $test) { $groups = []; if ($test instanceof ScenarioDriven) { $groups = $test->getScenario()->getGroups(); } if ($test instanceof Reported) { $info = $test->getReportFields(); if (isset($info['class'])) { $groups = array_merge($groups, \PHPUnit_Util_Test::getGroups($info['class'], $info['name'])); } $filename = $info['file']; } else { $groups = array_merge($groups, \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName(false))); $filename = (new \ReflectionClass($test))->getFileName(); } foreach ($this->testsInGroups as $group => $tests) { foreach ($tests as $testPattern) { if ($filename == $testPattern) { $groups[] = $group; } if (strpos($filename . ':' . $test->getName(false), $testPattern) === 0) { $groups[] = $group; } } } return array_unique($groups); }