From 00b9d1d658ec1e9fb8b2949dfc7b80b6ecc7c792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20VIGNELLES?= Date: Fri, 2 Aug 2024 17:18:36 +0200 Subject: [PATCH] fix(SymfonyConstraintAnnotationReader): added functional tests --- .../Entity/SymfonyConstraintsWithValidationGroups80.php | 8 ++++++++ .../Entity/SymfonyConstraintsWithValidationGroups81.php | 7 +++++++ tests/Functional/ValidationGroupsFunctionalTest.php | 8 ++++++++ 3 files changed, 23 insertions(+) diff --git a/tests/Functional/Entity/SymfonyConstraintsWithValidationGroups80.php b/tests/Functional/Entity/SymfonyConstraintsWithValidationGroups80.php index c03794602..4f1fda013 100644 --- a/tests/Functional/Entity/SymfonyConstraintsWithValidationGroups80.php +++ b/tests/Functional/Entity/SymfonyConstraintsWithValidationGroups80.php @@ -43,4 +43,12 @@ class SymfonyConstraintsWithValidationGroups80 * @Assert\Valid */ public $propertyArray; + + /** + * @var ?string + * + * @Groups({"test"}) + * @Assert\NotNull(groups={"test"}) + */ + public $propertyNotNullOnSpecificGroup; } diff --git a/tests/Functional/Entity/SymfonyConstraintsWithValidationGroups81.php b/tests/Functional/Entity/SymfonyConstraintsWithValidationGroups81.php index 609950221..cab5853a4 100644 --- a/tests/Functional/Entity/SymfonyConstraintsWithValidationGroups81.php +++ b/tests/Functional/Entity/SymfonyConstraintsWithValidationGroups81.php @@ -37,4 +37,11 @@ class SymfonyConstraintsWithValidationGroups81 #[OA\Property(type: 'array', items: new OA\Items(type: 'string'))] #[Assert\Valid] public $propertyArray; + + /** + * @var ?string + */ + #[Groups(['test'])] + #[Assert\NotNull(groups: ['test'])] + public $propertyNotNullOnSpecificGroup; } diff --git a/tests/Functional/ValidationGroupsFunctionalTest.php b/tests/Functional/ValidationGroupsFunctionalTest.php index ad522968b..3e43eee2b 100644 --- a/tests/Functional/ValidationGroupsFunctionalTest.php +++ b/tests/Functional/ValidationGroupsFunctionalTest.php @@ -35,6 +35,7 @@ public function testConstraintGroupsAreRespectedWhenDescribingModels(): void $expected = [ 'required' => [ 'property', + 'propertyNotNullOnSpecificGroup', ], 'properties' => [ 'property' => [ @@ -42,6 +43,9 @@ public function testConstraintGroupsAreRespectedWhenDescribingModels(): void // the min/max constraint is in the default group only and shouldn't // be read here with validation groups turned on ], + 'propertyNotNullOnSpecificGroup' => [ + 'type' => 'string', + ], ], 'type' => 'object', 'schema' => 'SymfonyConstraintsTestGroup', @@ -75,6 +79,10 @@ public function testConstraintDefaultGroupsAreRespectedWhenReadingAnnotations(): 'type' => 'string', ], ], + 'propertyNotNullOnSpecificGroup' => [ + 'type' => 'string', + 'nullable' => true, + ], ], 'type' => 'object', 'schema' => 'SymfonyConstraintsDefaultGroup',