Skip to content

Commit e507619

Browse files
minor #57823 [Validator] properly set up constraint options (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [Validator] properly set up constraint options | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT while working on #57812 I noticed that we did not properly set up some of the constraints which means that tests making use of constraint options were never tested correctly Commits ------- a3e0dc9 properly set up constraint options
2 parents fdea8b2 + a3e0dc9 commit e507619

4 files changed

+75
-16
lines changed

src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTest extends Greate
2323
{
2424
protected static function createConstraint(?array $options = null): Constraint
2525
{
26-
return new PositiveOrZero();
26+
return new PositiveOrZero($options);
2727
}
2828

2929
/**
@@ -92,6 +92,11 @@ public function testInvalidValuePath()
9292
$this->markTestSkipped('PropertyPath option is not used in PositiveOrZero constraint');
9393
}
9494

95+
public static function provideAllValidComparisons(): array
96+
{
97+
self::markTestSkipped('The "value" option cannot be used in the PositiveOrZero constraint');
98+
}
99+
95100
/**
96101
* @dataProvider provideValidComparisonsToPropertyPath
97102
*/
@@ -100,6 +105,11 @@ public function testValidComparisonToPropertyPath($comparedValue)
100105
$this->markTestSkipped('PropertyPath option is not used in PositiveOrZero constraint');
101106
}
102107

108+
public function testNoViolationOnNullObjectWithPropertyPath()
109+
{
110+
$this->markTestSkipped('PropertyPath option is not used in PositiveOrZero constraint');
111+
}
112+
103113
/**
104114
* @dataProvider throwsOnInvalidStringDatesProvider
105115
*/
@@ -112,4 +122,19 @@ public function testInvalidComparisonToPropertyPathAddsPathAsParameter()
112122
{
113123
$this->markTestSkipped('PropertyPath option is not used in PositiveOrZero constraint');
114124
}
125+
126+
public static function throwsOnInvalidStringDatesProvider(): array
127+
{
128+
self::markTestSkipped('The "value" option cannot be used in the PositiveOrZero constraint');
129+
}
130+
131+
public static function provideAllInvalidComparisons(): array
132+
{
133+
self::markTestSkipped('The "value" option cannot be used in the Negative constraint');
134+
}
135+
136+
public static function provideComparisonsToNullValueAtPropertyPath(): array
137+
{
138+
self::markTestSkipped('PropertyPath option is not used in PositiveOrZero constraint');
139+
}
115140
}

src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorWithPositiveConstraintTest.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class GreaterThanValidatorWithPositiveConstraintTest extends GreaterThanValidato
2323
{
2424
protected static function createConstraint(?array $options = null): Constraint
2525
{
26-
return new Positive();
26+
return new Positive($options);
2727
}
2828

2929
/**
@@ -95,6 +95,11 @@ public function testInvalidValuePath()
9595
$this->markTestSkipped('PropertyPath option is not used in Positive constraint');
9696
}
9797

98+
public static function provideAllValidComparisons(): array
99+
{
100+
self::markTestSkipped('The "value" option cannot be used in the Positive constraint');
101+
}
102+
98103
/**
99104
* @dataProvider provideValidComparisonsToPropertyPath
100105
*/
@@ -115,4 +120,19 @@ public function testInvalidComparisonToPropertyPathAddsPathAsParameter()
115120
{
116121
$this->markTestSkipped('PropertyPath option is not used in Positive constraint');
117122
}
123+
124+
public static function throwsOnInvalidStringDatesProvider(): array
125+
{
126+
self::markTestSkipped('The "value" option cannot be used in the Positive constraint');
127+
}
128+
129+
public static function provideAllInvalidComparisons(): array
130+
{
131+
self::markTestSkipped('The "value" option cannot be used in the Positive constraint');
132+
}
133+
134+
public static function provideComparisonsToNullValueAtPropertyPath(): array
135+
{
136+
self::markTestSkipped('PropertyPath option is not used in PositiveOrZero constraint');
137+
}
118138
}

src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class LessThanOrEqualValidatorWithNegativeOrZeroConstraintTest extends LessThanO
2323
{
2424
protected static function createConstraint(?array $options = null): Constraint
2525
{
26-
return new NegativeOrZero();
26+
return new NegativeOrZero($options);
2727
}
2828

2929
/**
@@ -95,6 +95,11 @@ public function testInvalidValuePath()
9595
$this->markTestSkipped('PropertyPath option is not used in NegativeOrZero constraint');
9696
}
9797

98+
public static function provideAllValidComparisons(): array
99+
{
100+
self::markTestSkipped('The "value" option cannot be used in the NegativeOrZero constraint');
101+
}
102+
98103
/**
99104
* @dataProvider provideValidComparisonsToPropertyPath
100105
*/
@@ -103,12 +108,9 @@ public function testValidComparisonToPropertyPath($comparedValue)
103108
$this->markTestSkipped('PropertyPath option is not used in NegativeOrZero constraint');
104109
}
105110

106-
/**
107-
* @dataProvider throwsOnInvalidStringDatesProvider
108-
*/
109-
public function testThrowsOnInvalidStringDates(AbstractComparison $constraint, $expectedMessage, $value)
111+
public function testInvalidComparisonToPropertyPathAddsPathAsParameter()
110112
{
111-
$this->markTestSkipped('The compared value cannot be an invalid string date because it is hardcoded to 0.');
113+
$this->markTestSkipped('PropertyPath option is not used in NegativeOrZero constraint');
112114
}
113115

114116
/**
@@ -119,8 +121,13 @@ public function testCompareWithNullValueAtPropertyAt($dirtyValue, $dirtyValueAsS
119121
$this->markTestSkipped('PropertyPath option is not used in NegativeOrZero constraint');
120122
}
121123

122-
public function testInvalidComparisonToPropertyPathAddsPathAsParameter()
124+
public static function throwsOnInvalidStringDatesProvider(): array
123125
{
124-
$this->markTestSkipped('PropertyPath option is not used in NegativeOrZero constraint');
126+
self::markTestSkipped('The "value" option cannot be used in the NegativeOrZero constraint');
127+
}
128+
129+
public static function provideAllInvalidComparisons(): array
130+
{
131+
self::markTestSkipped('The "value" option cannot be used in the NegativeOrZero constraint');
125132
}
126133
}

src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorWithNegativeConstraintTest.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class LessThanValidatorWithNegativeConstraintTest extends LessThanValidatorTest
2323
{
2424
protected static function createConstraint(?array $options = null): Constraint
2525
{
26-
return new Negative();
26+
return new Negative($options);
2727
}
2828

2929
/**
@@ -95,6 +95,11 @@ public function testInvalidValuePath()
9595
$this->markTestSkipped('PropertyPath option is not used in Negative constraint');
9696
}
9797

98+
public static function provideAllValidComparisons(): array
99+
{
100+
self::markTestSkipped('The "value" option cannot be used in the Negative constraint');
101+
}
102+
98103
/**
99104
* @dataProvider provideValidComparisonsToPropertyPath
100105
*/
@@ -103,12 +108,9 @@ public function testValidComparisonToPropertyPath($comparedValue)
103108
$this->markTestSkipped('PropertyPath option is not used in Negative constraint');
104109
}
105110

106-
/**
107-
* @dataProvider throwsOnInvalidStringDatesProvider
108-
*/
109-
public function testThrowsOnInvalidStringDates(AbstractComparison $constraint, $expectedMessage, $value)
111+
public static function throwsOnInvalidStringDatesProvider(): array
110112
{
111-
$this->markTestSkipped('The compared value cannot be an invalid string date because it is hardcoded to 0.');
113+
self::markTestSkipped('The "value" option cannot be used in the Negative constraint');
112114
}
113115

114116
/**
@@ -123,4 +125,9 @@ public function testInvalidComparisonToPropertyPathAddsPathAsParameter()
123125
{
124126
$this->markTestSkipped('PropertyPath option is not used in Negative constraint');
125127
}
128+
129+
public static function provideAllInvalidComparisons(): array
130+
{
131+
self::markTestSkipped('The "value" option cannot be used in the Negative constraint');
132+
}
126133
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy