Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed wildcard matching of group files #6302

Merged
merged 2 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/Codeception/Lib/GroupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +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++;
$prefix = str_replace('*', '', $group);
$pathPrefix = str_replace('*', '', basename($pattern));
$groupName = $prefix . str_replace($pathPrefix, '', $file->getRelativePathname());

$this->configuredGroups[$groupName] = dirname($pattern) . DIRECTORY_SEPARATOR . $file->getRelativePathname();
}

unset($this->configuredGroups[$group]);
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/data/group_manager_test/group_chunk_1_1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/data/group_manager_test/UserTest.php
1 change: 1 addition & 0 deletions tests/data/group_manager_test/group_chunk_1_2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/data/group_manager_test/PostTest.php
12 changes: 12 additions & 0 deletions tests/unit/Codeception/Lib/GroupManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,23 @@ public function testGroupsByPattern()
$this->assertContains('group_2', $this->manager->groupsForTest($test2));
}


public function testGroupsByPatternWithMultipleDigits()
{
$this->manager = new GroupManager(['group_chunk_*' => 'tests/data/group_manager_test/group_chunk_*']);
$test1 = $this->makeTestCase('tests/data/group_manager_test/UserTest.php');
$test2 = $this->makeTestCase('tests/data/group_manager_test/PostTest.php');

$this->assertContains('group_chunk_1_1', $this->manager->groupsForTest($test1));
$this->assertContains('group_chunk_1_2', $this->manager->groupsForTest($test2));
}

public function testGroupsByDifferentPattern()
{
$this->manager = new GroupManager(['g_*' => 'tests/data/group_manager_test/group_*']);
$test1 = $this->makeTestCase('tests/data/group_manager_test/UserTest.php');
$test2 = $this->makeTestCase('tests/data/group_manager_test/PostTest.php');
codecept_debug($this->manager->groupsForTest($test1));
$this->assertContains('g_1', $this->manager->groupsForTest($test1));
$this->assertContains('g_2', $this->manager->groupsForTest($test2));
}
Expand Down