diff --git a/src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php b/src/Symfony/Component/Validator/Constraints/OneOf.php similarity index 84% rename from src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php rename to src/Symfony/Component/Validator/Constraints/OneOf.php index ca726ae369102..b9297ed0540ff 100644 --- a/src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php +++ b/src/Symfony/Component/Validator/Constraints/OneOf.php @@ -17,12 +17,12 @@ * * @author Przemysław Bogusz */ -class AtLeastOneOf extends Composite +class OneOf extends Composite { - public const AT_LEAST_ONE_OF_ERROR = 'f27e6d6c-261a-4056-b391-6673a623531c'; + public const ONE_OF_ERROR = 'f27e6d6c-261a-4056-b391-6673a623531c'; protected static $errorNames = [ - self::AT_LEAST_ONE_OF_ERROR => 'AT_LEAST_ONE_OF_ERROR', + self::ONE_OF_ERROR => 'ONE_OF_ERROR', ]; public $constraints = []; diff --git a/src/Symfony/Component/Validator/Constraints/AtLeastOneOfValidator.php b/src/Symfony/Component/Validator/Constraints/OneOfValidator.php similarity index 85% rename from src/Symfony/Component/Validator/Constraints/AtLeastOneOfValidator.php rename to src/Symfony/Component/Validator/Constraints/OneOfValidator.php index acdd31117af84..0a637fdbefeb9 100644 --- a/src/Symfony/Component/Validator/Constraints/AtLeastOneOfValidator.php +++ b/src/Symfony/Component/Validator/Constraints/OneOfValidator.php @@ -18,15 +18,15 @@ /** * @author Przemysław Bogusz */ -class AtLeastOneOfValidator extends ConstraintValidator +class OneOfValidator extends ConstraintValidator { /** * {@inheritdoc} */ public function validate($value, Constraint $constraint) { - if (!$constraint instanceof AtLeastOneOf) { - throw new UnexpectedTypeException($constraint, AtLeastOneOf::class); + if (!$constraint instanceof OneOf) { + throw new UnexpectedTypeException($constraint, OneOf::class); } $validator = $this->context->getValidator(); @@ -54,7 +54,7 @@ public function validate($value, Constraint $constraint) } $this->context->buildViolation(implode('', $messages)) - ->setCode(AtLeastOneOf::AT_LEAST_ONE_OF_ERROR) + ->setCode(OneOf::ONE_OF_ERROR) ->addViolation() ; } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AtLeastOneOfTest.php b/src/Symfony/Component/Validator/Tests/Constraints/OneOfTest.php similarity index 84% rename from src/Symfony/Component/Validator/Tests/Constraints/AtLeastOneOfTest.php rename to src/Symfony/Component/Validator/Tests/Constraints/OneOfTest.php index b6cb95b259c48..08371e314a9e3 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AtLeastOneOfTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/OneOfTest.php @@ -12,18 +12,18 @@ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\TestCase; -use Symfony\Component\Validator\Constraints\AtLeastOneOf; +use Symfony\Component\Validator\Constraints\OneOf; use Symfony\Component\Validator\Constraints\Valid; /** * @author Przemysław Bogusz */ -class AtLeastOneOfTest extends TestCase +class OneOfTest extends TestCase { public function testRejectNonConstraints() { $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); - new AtLeastOneOf([ + new OneOf([ 'foo', ]); } @@ -31,7 +31,7 @@ public function testRejectNonConstraints() public function testRejectValidConstraint() { $this->expectException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); - new AtLeastOneOf([ + new OneOf([ new Valid(), ]); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AtLeastOneOfValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/OneOfValidatorTest.php similarity index 85% rename from src/Symfony/Component/Validator/Tests/Constraints/AtLeastOneOfValidatorTest.php rename to src/Symfony/Component/Validator/Tests/Constraints/OneOfValidatorTest.php index 2870781780117..75c715396ecc8 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AtLeastOneOfValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/OneOfValidatorTest.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Component\Validator\Constraints\AtLeastOneOf; -use Symfony\Component\Validator\Constraints\AtLeastOneOfValidator; use Symfony\Component\Validator\Constraints\Choice; use Symfony\Component\Validator\Constraints\Count; use Symfony\Component\Validator\Constraints\Country; @@ -24,6 +22,8 @@ use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\LessThan; use Symfony\Component\Validator\Constraints\Negative; +use Symfony\Component\Validator\Constraints\OneOf; +use Symfony\Component\Validator\Constraints\OneOfValidator; use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Constraints\Regex; use Symfony\Component\Validator\Constraints\Unique; @@ -32,11 +32,11 @@ /** * @author Przemysław Bogusz */ -class AtLeastOneOfValidatorTest extends ConstraintValidatorTestCase +class OneOfValidatorTest extends ConstraintValidatorTestCase { protected function createValidator() { - return new AtLeastOneOfValidator(); + return new OneOfValidator(); } /** @@ -50,7 +50,7 @@ public function testValidCombinations($value, $constraints) $this->expectViolationsAt($i++, $value, $constraint); } - $this->validator->validate($value, new AtLeastOneOf($constraints)); + $this->validator->validate($value, new OneOf($constraints)); $this->assertNoViolation(); } @@ -94,7 +94,7 @@ public function getValidCombinations() */ public function testInvalidCombinationsWithDefaultMessage($value, $constraints) { - $atLeastOneOf = new AtLeastOneOf(['constraints' => $constraints]); + $atLeastOneOf = new OneOf(['constraints' => $constraints]); $message = [$atLeastOneOf->message]; @@ -106,7 +106,7 @@ public function testInvalidCombinationsWithDefaultMessage($value, $constraints) $this->validator->validate($value, $atLeastOneOf); - $this->buildViolation(implode('', $message))->setCode(AtLeastOneOf::AT_LEAST_ONE_OF_ERROR)->assertRaised(); + $this->buildViolation(implode('', $message))->setCode(OneOf::ONE_OF_ERROR)->assertRaised(); } /** @@ -114,7 +114,7 @@ public function testInvalidCombinationsWithDefaultMessage($value, $constraints) */ public function testInvalidCombinationsWithCustomMessage($value, $constraints) { - $atLeastOneOf = new AtLeastOneOf(['constraints' => $constraints, 'message' => 'foo', 'includeInternalMessages' => false]); + $atLeastOneOf = new OneOf(['constraints' => $constraints, 'message' => 'foo', 'includeInternalMessages' => false]); $i = 0; @@ -124,7 +124,7 @@ public function testInvalidCombinationsWithCustomMessage($value, $constraints) $this->validator->validate($value, $atLeastOneOf); - $this->buildViolation('foo')->setCode(AtLeastOneOf::AT_LEAST_ONE_OF_ERROR)->assertRaised(); + $this->buildViolation('foo')->setCode(OneOf::ONE_OF_ERROR)->assertRaised(); } public function getInvalidCombinations()