Skip to content

Commit 301c1ca

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 0297b0b commit 301c1ca

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
@@ -215,7 +215,7 @@ public function setParamsFromAttributes($attributes): void
215215
$params = [];
216216
foreach ($attributes as $attribute) {
217217
$name = lcfirst(str_replace('Codeception\\Attribute\\', '', $attribute->getName()));
218-
if ($attribute->isRepeated()) {
218+
if ($attribute->isRepeated() || $name === 'examples') {
219219
$params[$name] ??= [];
220220
$params[$name][] = $attribute->getArguments();
221221
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) {
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) => $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