Skip to content

Commit 5e3d1d0

Browse files
author
Jeremiah VALERIE
committed
Fix composite validation test for Symfony < 5.1
1 parent 9ad3dac commit 5e3d1d0

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Overblog\GraphQLBundle\Tests\Functional\App\Validator;
6+
7+
use Symfony\Component\Validator\AtLeastOneOf as BaseAtLeastOneOf;
8+
use Symfony\Component\Validator\Constraint;
9+
10+
if (class_exists(BaseAtLeastOneOf::class)) {
11+
class AtLeastOneOf extends BaseAtLeastOneOf
12+
{
13+
}
14+
} else {
15+
class AtLeastOneOf extends Constraint
16+
{
17+
public string $message = 'Mock constraint';
18+
19+
/**
20+
* @var array
21+
*/
22+
public $constraints = [];
23+
24+
/**
25+
* @var bool
26+
*/
27+
public $includeInternalMessages = true;
28+
29+
/**
30+
* @return class-string
31+
*/
32+
public function validatedBy(): string
33+
{
34+
return MockValidator::class;
35+
}
36+
}
37+
}

tests/Functional/App/config/validator/mapping/Period.types.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Period:
66
type: String!
77
validation:
88
- Date: ~
9-
- AtLeastOneOf:
9+
- Overblog\GraphQLBundle\Tests\Functional\App\Validator\AtLeastOneOf:
1010
constraints:
1111
- GreaterThanOrEqual: '-100 years'
1212
message: "Year should be GreaterThanOrEqual -100."

0 commit comments

Comments
 (0)