Skip to content

Commit

Permalink
fix(SymfonyConstraintAnnotationReader): added functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyVignelles committed Aug 2, 2024
1 parent b5b8149 commit 00b9d1d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,12 @@ class SymfonyConstraintsWithValidationGroups80
* @Assert\Valid
*/
public $propertyArray;

/**
* @var ?string
*
* @Groups({"test"})
* @Assert\NotNull(groups={"test"})
*/
public $propertyNotNullOnSpecificGroup;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
8 changes: 8 additions & 0 deletions tests/Functional/ValidationGroupsFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ public function testConstraintGroupsAreRespectedWhenDescribingModels(): void
$expected = [
'required' => [
'property',
'propertyNotNullOnSpecificGroup',
],
'properties' => [
'property' => [
'type' => 'integer',
// 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',
Expand Down Expand Up @@ -75,6 +79,10 @@ public function testConstraintDefaultGroupsAreRespectedWhenReadingAnnotations():
'type' => 'string',
],
],
'propertyNotNullOnSpecificGroup' => [
'type' => 'string',
'nullable' => true,
],
],
'type' => 'object',
'schema' => 'SymfonyConstraintsDefaultGroup',
Expand Down

0 comments on commit 00b9d1d

Please sign in to comment.