From ec066f3ede77f92f699cc63209cff09cc4f40d76 Mon Sep 17 00:00:00 2001 From: "Daniel Hansmann @ Aldi Digital Services" <83207188+DanielHansmannAldi@users.noreply.github.com> Date: Tue, 21 Dec 2021 17:41:07 +0100 Subject: [PATCH 1/3] Patch Group Creation with Wildcard Patch Group Creation with Wildcard to realy work with Filename and not only iterate $i --- src/Codeception/Lib/GroupManager.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Codeception/Lib/GroupManager.php b/src/Codeception/Lib/GroupManager.php index f1ecdf7469..5063d0429b 100644 --- a/src/Codeception/Lib/GroupManager.php +++ b/src/Codeception/Lib/GroupManager.php @@ -56,13 +56,15 @@ 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]); } From fc07033ff7ec720960f5642e469c8938378355a0 Mon Sep 17 00:00:00 2001 From: "Daniel Hansmann @ Aldi Digital Services" <83207188+DanielHansmannAldi@users.noreply.github.com> Date: Tue, 21 Dec 2021 17:57:33 +0100 Subject: [PATCH 2/3] Styling --- src/Codeception/Lib/GroupManager.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Codeception/Lib/GroupManager.php b/src/Codeception/Lib/GroupManager.php index 5063d0429b..ada0763c4a 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; @@ -59,9 +60,9 @@ protected function loadGroupsByPattern() foreach ($files as $file) { /** @var SplFileInfo $file * */ $filename = $file->getRelativePathname(); - $regex = "/".str_replace("*","(.*)",$group)."/"; + $regex = "/".str_replace("*", "(.*)", $group)."/"; preg_match_all($regex, $filename, $matches, PREG_SET_ORDER, 0); - if(isset($matches[0][1])) + if (isset($matches[0][1])) { $this->configuredGroups[str_replace('*', $matches[0][1], $group)] = dirname($pattern).DIRECTORY_SEPARATOR.$file->getRelativePathname(); } From adca05da8cf72d6d8b842d54b81ae058ba83f1c2 Mon Sep 17 00:00:00 2001 From: "Daniel Hansmann @ Aldi Digital Services" <83207188+DanielHansmannAldi@users.noreply.github.com> Date: Tue, 21 Dec 2021 18:01:46 +0100 Subject: [PATCH 3/3] Styling 2 --- src/Codeception/Lib/GroupManager.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Codeception/Lib/GroupManager.php b/src/Codeception/Lib/GroupManager.php index ada0763c4a..9109d2f018 100644 --- a/src/Codeception/Lib/GroupManager.php +++ b/src/Codeception/Lib/GroupManager.php @@ -62,8 +62,7 @@ protected function loadGroupsByPattern() $filename = $file->getRelativePathname(); $regex = "/".str_replace("*", "(.*)", $group)."/"; preg_match_all($regex, $filename, $matches, PREG_SET_ORDER, 0); - if (isset($matches[0][1])) - { + if (isset($matches[0][1])) { $this->configuredGroups[str_replace('*', $matches[0][1], $group)] = dirname($pattern).DIRECTORY_SEPARATOR.$file->getRelativePathname(); } }