Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #31511 [Validator] Allow to use property paths to get limits …
…in range constraint (Lctrs) This PR was squashed before being merged into the 4.4 branch (closes #31511). Discussion ---------- [Validator] Allow to use property paths to get limits in range constraint | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | Part of #31503 | License | MIT | Doc PR | symfony/symfony-docs#11793 Similar as #22576, but for the `Range` constraint. Commits ------- 2b50990 [Validator] Allow to use property paths to get limits in range constraint
- Loading branch information
Showing
5 changed files
with
547 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/Symfony/Component/Validator/Tests/Constraints/RangeTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\Validator\Tests\Constraints; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Validator\Constraints\Range; | ||
|
||
class RangeTest extends TestCase | ||
{ | ||
/** | ||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException | ||
* @expectedExceptionMessage requires only one of the "min" or "minPropertyPath" options to be set, not both. | ||
*/ | ||
public function testThrowsConstraintExceptionIfBothMinLimitAndPropertyPath() | ||
{ | ||
new Range([ | ||
'min' => 'min', | ||
'minPropertyPath' => 'minPropertyPath', | ||
]); | ||
} | ||
|
||
/** | ||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException | ||
* @expectedExceptionMessage requires only one of the "max" or "maxPropertyPath" options to be set, not both. | ||
*/ | ||
public function testThrowsConstraintExceptionIfBothMaxLimitAndPropertyPath() | ||
{ | ||
new Range([ | ||
'max' => 'min', | ||
'maxPropertyPath' => 'maxPropertyPath', | ||
]); | ||
} | ||
|
||
/** | ||
* @expectedException \Symfony\Component\Validator\Exception\MissingOptionsException | ||
* @expectedExceptionMessage Either option "min", "minPropertyPath", "max" or "maxPropertyPath" must be given | ||
*/ | ||
public function testThrowsConstraintExceptionIfNoLimitNorPropertyPath() | ||
{ | ||
new Range([]); | ||
} | ||
|
||
/** | ||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException | ||
* @expectedExceptionMessage No default option is configured | ||
*/ | ||
public function testThrowsNoDefaultOptionConfiguredException() | ||
{ | ||
new Range('value'); | ||
} | ||
} |
Oops, something went wrong.