Skip to content

Commit 8fac2b3

Browse files
committed
Added data providers support in failed group
1 parent 8e8a7ec commit 8fac2b3

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

ext/RunFailed.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,12 @@ public function saveFailed(PrintResultEvent $event): void
7676
}
7777
$output = [];
7878
foreach ($result->failures() as $fail) {
79-
$output[] = $this->localizePath(Descriptor::getTestFullName($fail->getTest()));
79+
$output[] = $this->localizePath(Descriptor::getTestFullName($fail->getTest()))
80+
. $fail->getTest()->getMetadata()->getIndexTextSuffix();
8081
}
8182
foreach ($result->errors() as $fail) {
82-
$output[] = $this->localizePath(Descriptor::getTestFullName($fail->getTest()));
83+
$output[] = $this->localizePath(Descriptor::getTestFullName($fail->getTest()))
84+
. $fail->getTest()->getMetadata()->getIndexTextSuffix();
8385
}
8486

8587
file_put_contents($file, implode("\n", $output));

src/Codeception/Lib/GroupManager.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,12 @@ public function groupsForTest(Test $test): array
144144
$filename = realpath($test->getFileName());
145145
$testName = $test->getName();
146146
$groups = $test->getMetadata()->getGroups();
147+
$indexName = $test->getMetadata()->getIndexTextSuffix();
147148

148149
foreach ($this->testsInGroups as $group => $tests) {
149150
/** @var string[] $tests */
150151
foreach ($tests as $testPattern) {
151-
if ($filename == $testPattern || str_starts_with($filename . ':' . $testName, $testPattern)) {
152+
if ($filename == $testPattern || str_starts_with($filename . ':' . $testName . $indexName, $testPattern)) {
152153
$groups[] = $group;
153154
}
154155
if (

src/Codeception/Test/Metadata.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ class Metadata
1919
protected int|string|null $index = null;
2020

2121
protected array $params = [
22-
'env' => [],
23-
'group' => [],
24-
'depends' => [],
25-
'skip' => null,
22+
'env' => [],
23+
'group' => [],
24+
'depends' => [],
25+
'skip' => null,
2626
'incomplete' => null,
2727
];
2828

29-
protected array $current = [];
29+
protected array $current = [];
3030
protected array $services = [];
31-
protected array $reports = [];
31+
protected array $reports = [];
3232

3333
/** @var string[] */
3434
private array $beforeClassMethods = [];
3535

3636
/** @var string[] */
37-
private array $afterClassMethods = [];
37+
private array $afterClassMethods = [];
3838

3939
public function getEnv(): array
4040
{
@@ -126,6 +126,16 @@ public function isBlocked(): bool
126126
return $this->getSkip() !== null || $this->getIncomplete() !== null;
127127
}
128128

129+
public function getIndexTextSuffix(): string
130+
{
131+
if (is_int($this->index)) {
132+
return '#' . $this->index;
133+
} elseif (is_string($this->index)) {
134+
return '@' . $this->index;
135+
}
136+
return '';
137+
}
138+
129139
public function getFeature(): string
130140
{
131141
return $this->feature;
@@ -172,7 +182,7 @@ public function setParamsFromAnnotations($annotations): void
172182
{
173183
$this->params = array_merge_recursive(
174184
$this->params,
175-
Annotation::fetchAllAnnotationsFromDocblock((string) $annotations)
185+
Annotation::fetchAllAnnotationsFromDocblock((string)$annotations)
176186
);
177187
$this->setSingularValueForSomeParams();
178188
}
@@ -191,7 +201,7 @@ public function setParamsFromAttributes($attributes): void
191201
{
192202
$params = [];
193203
foreach ($attributes as $attribute) {
194-
$name = lcfirst(str_replace('Codeception\\Attribute\\', '', (string) $attribute->getName()));
204+
$name = lcfirst(str_replace('Codeception\\Attribute\\', '', (string)$attribute->getName()));
195205
$arguments = $attribute->getArguments();
196206

197207
if ($attribute->isRepeated()) {
@@ -206,7 +216,7 @@ public function setParamsFromAttributes($attributes): void
206216
foreach (['group', 'env', 'before', 'after', 'prepare'] as $single) {
207217
if (isset($this->params[$single]) && is_array($this->params[$single])) {
208218
$this->params[$single] = array_merge(
209-
...array_map(static fn($a): array => (array) $a, $this->params[$single])
219+
...array_map(static fn($a): array => (array)$a, $this->params[$single])
210220
);
211221
}
212222
}

0 commit comments

Comments
 (0)