Skip to content

Commit 8781c1a

Browse files
committed
Allow a test with only one #Examples() attribute
If a cest test does only have one `#Examples()` attribute it is not handled as if there are multiple but an InjectionException occurs. The Examples attribute does now also work if it is not repeated
1 parent e2c300b commit 8781c1a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Codeception/Test/Metadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public function setParamsFromAttributes($attributes): void
219219
$params = [];
220220
foreach ($attributes as $attribute) {
221221
$name = lcfirst(str_replace('Codeception\\Attribute\\', '', (string) $attribute->getName()));
222-
if ($attribute->isRepeated()) {
222+
if ($attribute->isRepeated() || $name === 'examples') {
223223
$params[$name] ??= [];
224224
$params[$name][] = $attribute->getArguments();
225225
continue;

src/Codeception/Util/Annotation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ public function fetchAll(string $annotation): array
129129
{
130130
$attr = $this->attribute($annotation);
131131
if ($attr instanceof ReflectionAttribute) {
132-
if (!$attr->isRepeated()) {
133-
return $attr->getArguments();
134-
}
135-
$attrs = $this->attributes();
136132
if ($annotation === 'example') {
137133
$annotation = 'examples'; // we renamed this annotation
138134
}
135+
if (!$attr->isRepeated() && $annotation !== 'examples') {
136+
return $attr->getArguments();
137+
}
138+
$attrs = $this->attributes();
139139
$name = ucfirst($annotation);
140140
$attrs = array_filter($attrs, fn ($a): bool => $a->getName() === "Codeception\\Attribute\\$name");
141141
if ($annotation === 'examples') {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy