Skip to content

Commit eb6077d

Browse files
committed
Use PHPUnit attribute in another data provider
1 parent c4c2cf1 commit eb6077d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

validation/custom_constraint.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ class to simplify writing unit tests for your custom constraints::
563563

564564
use App\Validator\ContainsAlphanumeric;
565565
use App\Validator\ContainsAlphanumericValidator;
566+
use PHPUnit\Framework\Attributes\DataProvider;
566567
use Symfony\Component\Validator\ConstraintValidatorInterface;
567568
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
568569

@@ -580,9 +581,7 @@ class to simplify writing unit tests for your custom constraints::
580581
$this->assertNoViolation();
581582
}
582583

583-
/**
584-
* @dataProvider provideInvalidConstraints
585-
*/
584+
#[DataProvider('provideInvalidConstraints')]
586585
public function testTrueIsInvalid(ContainsAlphanumeric $constraint): void
587586
{
588587
$this->validator->validate('...', $constraint);
@@ -592,7 +591,7 @@ class to simplify writing unit tests for your custom constraints::
592591
->assertRaised();
593592
}
594593

595-
public function provideInvalidConstraints(): \Generator
594+
public static function provideInvalidConstraints(): \Generator
596595
{
597596
yield [new ContainsAlphanumeric(message: 'myMessage')];
598597
// ...

0 commit comments

Comments
 (0)