mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
move coversNothing to method annotations
This commit is contained in:
@ -114,8 +114,9 @@ final class TestCaseMethodFactory
|
||||
* Creates a PHPUnit method as a string ready for evaluation.
|
||||
*
|
||||
* @param array<int, class-string> $annotationsToUse
|
||||
* @param array<int, class-string<\Pest\Factories\Attributes\Attribute>> $attributesToUse
|
||||
*/
|
||||
public function buildForEvaluation(string $classFQN, array $annotationsToUse): string
|
||||
public function buildForEvaluation(string $classFQN, array $annotationsToUse, array $attributesToUse): string
|
||||
{
|
||||
if ($this->description === null) {
|
||||
throw ShouldNotHappen::fromMessage('The test description may not be empty.');
|
||||
@ -129,12 +130,18 @@ final class TestCaseMethodFactory
|
||||
|
||||
$datasetsCode = '';
|
||||
$annotations = ['@test'];
|
||||
$attributes = [];
|
||||
|
||||
foreach ($annotationsToUse as $annotation) {
|
||||
/** @phpstan-ignore-next-line */
|
||||
$annotations = (new $annotation())->__invoke($this, $annotations);
|
||||
}
|
||||
|
||||
foreach ($attributesToUse as $attribute) {
|
||||
/** @phpstan-ignore-next-line */
|
||||
$attributes = (new $attribute())->__invoke($this, $attributes);
|
||||
}
|
||||
|
||||
if (count($this->datasets) > 0) {
|
||||
$dataProviderName = $methodName . '_dataset';
|
||||
$annotations[] = "@dataProvider $dataProviderName";
|
||||
@ -145,10 +152,15 @@ final class TestCaseMethodFactory
|
||||
static fn ($annotation) => sprintf("\n * %s", $annotation), $annotations,
|
||||
));
|
||||
|
||||
$attributes = implode('', array_map(
|
||||
static fn ($attribute) => sprintf("\n %s", $attribute), $attributes,
|
||||
));
|
||||
|
||||
return <<<EOF
|
||||
|
||||
/**$annotations
|
||||
*/
|
||||
$attributes
|
||||
public function $methodName()
|
||||
{
|
||||
return \$this->__runTest(
|
||||
|
||||
Reference in New Issue
Block a user