diff --git a/src/Codeception/Lib/GroupManager.php b/src/Codeception/Lib/GroupManager.php index f1ecdf7469..9109d2f018 100644 --- a/src/Codeception/Lib/GroupManager.php +++ b/src/Codeception/Lib/GroupManager.php @@ -46,6 +46,7 @@ protected function loadGroupsByPattern() if (strpos($group, '*') === false) { continue; } + $path = dirname($pattern); if (!\Codeception\Util\PathResolver::isPathAbsolute($pattern)) { $path = $this->rootDir . $path; @@ -56,13 +57,14 @@ protected function loadGroupsByPattern() ->sortByName() ->in($path); - $i = 1; - - foreach ($files as $file) { /** @var SplFileInfo $file * */ - $this->configuredGroups[str_replace('*', $i, $group)] = dirname($pattern).DIRECTORY_SEPARATOR.$file->getRelativePathname(); - $i++; + $filename = $file->getRelativePathname(); + $regex = "/".str_replace("*", "(.*)", $group)."/"; + preg_match_all($regex, $filename, $matches, PREG_SET_ORDER, 0); + if (isset($matches[0][1])) { + $this->configuredGroups[str_replace('*', $matches[0][1], $group)] = dirname($pattern).DIRECTORY_SEPARATOR.$file->getRelativePathname(); + } } unset($this->configuredGroups[$group]); }