diff --git a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php index 6369115f49..880e71d39a 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php +++ b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php @@ -158,6 +158,8 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface case 'Symfony\Component\Validator\Constraints\True': case 'Symfony\Component\Validator\Constraints\False': + case 'Symfony\Component\Validator\Constraints\IsTrue': + case 'Symfony\Component\Validator\Constraints\IsFalse': return new TypeGuess('checkbox', array(), Guess::MEDIUM_CONFIDENCE); } } @@ -175,6 +177,7 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface case 'Symfony\Component\Validator\Constraints\NotNull': case 'Symfony\Component\Validator\Constraints\NotBlank': case 'Symfony\Component\Validator\Constraints\True': + case 'Symfony\Component\Validator\Constraints\IsTrue': return new ValueGuess(true, Guess::HIGH_CONFIDENCE); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php index 61b2a917ec..654f6d5d2f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php @@ -19,7 +19,7 @@ use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Range; -use Symfony\Component\Validator\Constraints\True; +use Symfony\Component\Validator\Constraints\IsTrue; use Symfony\Component\Validator\Constraints\Type; use Symfony\Component\Validator\Mapping\ClassMetadata; @@ -64,7 +64,7 @@ class ValidatorTypeGuesserTest extends \PHPUnit_Framework_TestCase return array( array(new NotNull(), new ValueGuess(true, Guess::HIGH_CONFIDENCE)), array(new NotBlank(), new ValueGuess(true, Guess::HIGH_CONFIDENCE)), - array(new True(), new ValueGuess(true, Guess::HIGH_CONFIDENCE)), + array(new IsTrue(), new ValueGuess(true, Guess::HIGH_CONFIDENCE)), array(new Length(10), new ValueGuess(false, Guess::LOW_CONFIDENCE)), array(new Range(array('min' => 1, 'max' => 20)), new ValueGuess(false, Guess::LOW_CONFIDENCE)), ); @@ -84,6 +84,18 @@ class ValidatorTypeGuesserTest extends \PHPUnit_Framework_TestCase $this->assertEquals($guess, $this->guesser->guessRequired(self::TEST_CLASS, self::TEST_PROPERTY)); } + /** + * @group legacy + */ + public function testLegacyGuessRequired() + { + if (PHP_VERSION_ID >= 70000) { + $this->markTestSkipped('Cannot use a class called True on PHP 7 or higher.'); + } + $true = 'Symfony\Component\Validator\Constraints\True'; + $this->testGuessRequired(new $true(), new ValueGuess(true, Guess::HIGH_CONFIDENCE)); + } + public function testGuessRequiredReturnsFalseForUnmappedProperties() { $this->assertEquals(new ValueGuess(false, Guess::LOW_CONFIDENCE), $this->guesser->guessRequired(self::TEST_CLASS, self::TEST_PROPERTY)); diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index 60af900f62..21c6af6799 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -25,7 +25,7 @@ "require-dev": { "symfony/phpunit-bridge": "~2.7", "doctrine/collections": "~1.0", - "symfony/validator": "~2.6", + "symfony/validator": "~2.6,>=2.6.8", "symfony/http-foundation": "~2.2", "symfony/http-kernel": "~2.4", "symfony/security-csrf": "~2.4", diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php index 56e7eb2325..0bc012ac37 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -87,7 +87,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase // defining the timeout before the actual method call // allows to test for "greater than" values in the $criteria - $testTimeout = time(); + $testTimeout = time() + 1; $collection->expects($this->once()) ->method('findOne') diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php index c2cafc37b8..f64d7247c0 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php @@ -93,6 +93,19 @@ class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase $this->assertTrue($called2); } + public function testListenerCanRemoveItselfWhenExecuted() + { + $eventDispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); + $listener1 = function () use ($eventDispatcher, &$listener1) { + $eventDispatcher->removeListener('foo', $listener1); + }; + $eventDispatcher->addListener('foo', $listener1); + $eventDispatcher->addListener('foo', function () {}); + $eventDispatcher->dispatch('foo'); + + $this->assertCount(1, $eventDispatcher->getListeners('foo'), 'expected listener1 to be removed'); + } + protected function getHttpKernel($dispatcher, $controller) { $resolver = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface'); diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index dc925b75bd..db44225058 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -87,6 +87,11 @@ CHANGELOG * added a constraint the uses the expression language * added `minRatio`, `maxRatio`, `allowSquare`, `allowLandscape`, and `allowPortrait` to Image validator +2.3.29 +------ + + * fixed compatibility with PHP7 and up by introducing new constraints (IsNull, IsTrue, IsFalse) and related validators (IsNullValidator, IsTrueValidator, IsFalseValidator) + 2.3.0 ----- diff --git a/src/Symfony/Component/Validator/Constraints/False.php b/src/Symfony/Component/Validator/Constraints/False.php index fc2e3e49cb..6ec76ee3d1 100644 --- a/src/Symfony/Component/Validator/Constraints/False.php +++ b/src/Symfony/Component/Validator/Constraints/False.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Validator\Constraints; -use Symfony\Component\Validator\Constraint; - /** * @Annotation * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) @@ -21,7 +19,4 @@ use Symfony\Component\Validator\Constraint; * * @api */ -class False extends Constraint -{ - public $message = 'This value should be false.'; -} +class False extends IsFalse {} diff --git a/src/Symfony/Component/Validator/Constraints/FalseValidator.php b/src/Symfony/Component/Validator/Constraints/FalseValidator.php index 52f5ed397a..72fd1d44d1 100644 --- a/src/Symfony/Component/Validator/Constraints/FalseValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FalseValidator.php @@ -11,39 +11,9 @@ namespace Symfony\Component\Validator\Constraints; -use Symfony\Component\Validator\Context\ExecutionContextInterface; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - /** * @author Bernhard Schussek * * @api */ -class FalseValidator extends ConstraintValidator -{ - /** - * {@inheritdoc} - */ - public function validate($value, Constraint $constraint) - { - if (!$constraint instanceof False) { - throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\False'); - } - - if (null === $value || false === $value || 0 === $value || '0' === $value) { - return; - } - - if ($this->context instanceof ExecutionContextInterface) { - $this->context->buildViolation($constraint->message) - ->setParameter('{{ value }}', $this->formatValue($value)) - ->addViolation(); - } else { - $this->buildViolation($constraint->message) - ->setParameter('{{ value }}', $this->formatValue($value)) - ->addViolation(); - } - } -} +class FalseValidator extends IsFalseValidator {} diff --git a/src/Symfony/Component/Validator/Constraints/IsFalse.php b/src/Symfony/Component/Validator/Constraints/IsFalse.php new file mode 100644 index 0000000000..7b1b72bd51 --- /dev/null +++ b/src/Symfony/Component/Validator/Constraints/IsFalse.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; + +/** + * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) + * + * @author Bernhard Schussek + * + * @api + */ +class IsFalse extends Constraint +{ + public $message = 'This value should be false.'; +} diff --git a/src/Symfony/Component/Validator/Constraints/IsFalseValidator.php b/src/Symfony/Component/Validator/Constraints/IsFalseValidator.php new file mode 100644 index 0000000000..f5215588f2 --- /dev/null +++ b/src/Symfony/Component/Validator/Constraints/IsFalseValidator.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Context\ExecutionContextInterface; +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; + +/** + * @author Bernhard Schussek + * + * @api + */ +class IsFalseValidator extends ConstraintValidator +{ + /** + * {@inheritdoc} + */ + public function validate($value, Constraint $constraint) + { + if (!$constraint instanceof IsFalse) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\IsFalse'); + } + + if (null === $value || false === $value || 0 === $value || '0' === $value) { + return; + } + + if ($this->context instanceof ExecutionContextInterface) { + $this->context->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + } else { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + } + } +} diff --git a/src/Symfony/Component/Validator/Constraints/IsNull.php b/src/Symfony/Component/Validator/Constraints/IsNull.php new file mode 100644 index 0000000000..3e7fef112c --- /dev/null +++ b/src/Symfony/Component/Validator/Constraints/IsNull.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; + +/** + * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) + * + * @author Bernhard Schussek + * + * @api + */ +class IsNull extends Constraint +{ + public $message = 'This value should be null.'; +} diff --git a/src/Symfony/Component/Validator/Constraints/IsNullValidator.php b/src/Symfony/Component/Validator/Constraints/IsNullValidator.php new file mode 100644 index 0000000000..162f6182ff --- /dev/null +++ b/src/Symfony/Component/Validator/Constraints/IsNullValidator.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Context\ExecutionContextInterface; +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; + +/** + * @author Bernhard Schussek + * + * @api + */ +class IsNullValidator extends ConstraintValidator +{ + /** + * {@inheritdoc} + */ + public function validate($value, Constraint $constraint) + { + if (!$constraint instanceof IsNull) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\IsNull'); + } + + if (null !== $value) { + if ($this->context instanceof ExecutionContextInterface) { + $this->context->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + } else { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + } + } + } +} diff --git a/src/Symfony/Component/Validator/Constraints/IsTrue.php b/src/Symfony/Component/Validator/Constraints/IsTrue.php new file mode 100644 index 0000000000..c0be6b8272 --- /dev/null +++ b/src/Symfony/Component/Validator/Constraints/IsTrue.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Constraint; + +/** + * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) + * + * @author Bernhard Schussek + * + * @api + */ +class IsTrue extends Constraint +{ + public $message = 'This value should be true.'; +} diff --git a/src/Symfony/Component/Validator/Constraints/IsTrueValidator.php b/src/Symfony/Component/Validator/Constraints/IsTrueValidator.php new file mode 100644 index 0000000000..206c63d9a7 --- /dev/null +++ b/src/Symfony/Component/Validator/Constraints/IsTrueValidator.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Constraints; + +use Symfony\Component\Validator\Context\ExecutionContextInterface; +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; + +/** + * @author Bernhard Schussek + * + * @api + */ +class IsTrueValidator extends ConstraintValidator +{ + /** + * {@inheritdoc} + */ + public function validate($value, Constraint $constraint) + { + if (!$constraint instanceof IsTrue) { + throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\IsTrue'); + } + + if (null === $value) { + return; + } + + if (true !== $value && 1 !== $value && '1' !== $value) { + if ($this->context instanceof ExecutionContextInterface) { + $this->context->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + } else { + $this->buildViolation($constraint->message) + ->setParameter('{{ value }}', $this->formatValue($value)) + ->addViolation(); + } + } + } +} diff --git a/src/Symfony/Component/Validator/Constraints/Null.php b/src/Symfony/Component/Validator/Constraints/Null.php index 310455021b..5ad789cef8 100644 --- a/src/Symfony/Component/Validator/Constraints/Null.php +++ b/src/Symfony/Component/Validator/Constraints/Null.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Validator\Constraints; -use Symfony\Component\Validator\Constraint; - /** * @Annotation * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) @@ -21,7 +19,4 @@ use Symfony\Component\Validator\Constraint; * * @api */ -class Null extends Constraint -{ - public $message = 'This value should be null.'; -} +class Null extends IsNull {} diff --git a/src/Symfony/Component/Validator/Constraints/NullValidator.php b/src/Symfony/Component/Validator/Constraints/NullValidator.php index 5093331d2e..876924f375 100644 --- a/src/Symfony/Component/Validator/Constraints/NullValidator.php +++ b/src/Symfony/Component/Validator/Constraints/NullValidator.php @@ -11,37 +11,9 @@ namespace Symfony\Component\Validator\Constraints; -use Symfony\Component\Validator\Context\ExecutionContextInterface; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - /** * @author Bernhard Schussek * * @api */ -class NullValidator extends ConstraintValidator -{ - /** - * {@inheritdoc} - */ - public function validate($value, Constraint $constraint) - { - if (!$constraint instanceof Null) { - throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Null'); - } - - if (null !== $value) { - if ($this->context instanceof ExecutionContextInterface) { - $this->context->buildViolation($constraint->message) - ->setParameter('{{ value }}', $this->formatValue($value)) - ->addViolation(); - } else { - $this->buildViolation($constraint->message) - ->setParameter('{{ value }}', $this->formatValue($value)) - ->addViolation(); - } - } - } -} +class NullValidator extends IsNullValidator {} diff --git a/src/Symfony/Component/Validator/Constraints/True.php b/src/Symfony/Component/Validator/Constraints/True.php index 788e36a9ee..832b84b92b 100644 --- a/src/Symfony/Component/Validator/Constraints/True.php +++ b/src/Symfony/Component/Validator/Constraints/True.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Validator\Constraints; -use Symfony\Component\Validator\Constraint; - /** * @Annotation * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) @@ -21,7 +19,4 @@ use Symfony\Component\Validator\Constraint; * * @api */ -class True extends Constraint -{ - public $message = 'This value should be true.'; -} +class True extends IsTrue {} diff --git a/src/Symfony/Component/Validator/Constraints/TrueValidator.php b/src/Symfony/Component/Validator/Constraints/TrueValidator.php index 2c0340c0b7..fb0b7d6cdd 100644 --- a/src/Symfony/Component/Validator/Constraints/TrueValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TrueValidator.php @@ -11,41 +11,9 @@ namespace Symfony\Component\Validator\Constraints; -use Symfony\Component\Validator\Context\ExecutionContextInterface; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - /** * @author Bernhard Schussek * * @api */ -class TrueValidator extends ConstraintValidator -{ - /** - * {@inheritdoc} - */ - public function validate($value, Constraint $constraint) - { - if (!$constraint instanceof True) { - throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\True'); - } - - if (null === $value) { - return; - } - - if (true !== $value && 1 !== $value && '1' !== $value) { - if ($this->context instanceof ExecutionContextInterface) { - $this->context->buildViolation($constraint->message) - ->setParameter('{{ value }}', $this->formatValue($value)) - ->addViolation(); - } else { - $this->buildViolation($constraint->message) - ->setParameter('{{ value }}', $this->formatValue($value)) - ->addViolation(); - } - } - } -} +class TrueValidator extends IsTrueValidator {} diff --git a/src/Symfony/Component/Validator/README.md b/src/Symfony/Component/Validator/README.md index 2a370557c7..9014ec6724 100644 --- a/src/Symfony/Component/Validator/README.md +++ b/src/Symfony/Component/Validator/README.md @@ -81,7 +81,7 @@ class User } /** - * @Assert\True(message = "The user should have a Google Mail account") + * @Assert\IsTrue(message = "The user should have a Google Mail account") */ public function isGmailUser() { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsFalseValidatorTest.php similarity index 71% rename from src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php rename to src/Symfony/Component/Validator/Tests/Constraints/IsFalseValidatorTest.php index 479888e53b..a63d8466ad 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsFalseValidatorTest.php @@ -11,11 +11,11 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Component\Validator\Constraints\False; -use Symfony\Component\Validator\Constraints\FalseValidator; +use Symfony\Component\Validator\Constraints\IsFalse; +use Symfony\Component\Validator\Constraints\IsFalseValidator; use Symfony\Component\Validator\Validation; -class FalseValidatorTest extends AbstractConstraintValidatorTest +class IsFalseValidatorTest extends AbstractConstraintValidatorTest { protected function getApiVersion() { @@ -24,26 +24,26 @@ class FalseValidatorTest extends AbstractConstraintValidatorTest protected function createValidator() { - return new FalseValidator(); + return new IsFalseValidator(); } public function testNullIsValid() { - $this->validator->validate(null, new False()); + $this->validator->validate(null, new IsFalse()); $this->assertNoViolation(); } public function testFalseIsValid() { - $this->validator->validate(false, new False()); + $this->validator->validate(false, new IsFalse()); $this->assertNoViolation(); } public function testTrueIsInvalid() { - $constraint = new False(array( + $constraint = new IsFalse(array( 'message' => 'myMessage', )); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsNullValidatorTest.php similarity index 80% rename from src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php rename to src/Symfony/Component/Validator/Tests/Constraints/IsNullValidatorTest.php index 85df90a8ae..885048b9bd 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsNullValidatorTest.php @@ -11,11 +11,11 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Component\Validator\Constraints\Null; -use Symfony\Component\Validator\Constraints\NullValidator; +use Symfony\Component\Validator\Constraints\IsNull; +use Symfony\Component\Validator\Constraints\IsNullValidator; use Symfony\Component\Validator\Validation; -class NullValidatorTest extends AbstractConstraintValidatorTest +class IsNullValidatorTest extends AbstractConstraintValidatorTest { protected function getApiVersion() { @@ -24,12 +24,12 @@ class NullValidatorTest extends AbstractConstraintValidatorTest protected function createValidator() { - return new NullValidator(); + return new IsNullValidator(); } public function testNullIsValid() { - $this->validator->validate(null, new Null()); + $this->validator->validate(null, new IsNull()); $this->assertNoViolation(); } @@ -39,7 +39,7 @@ class NullValidatorTest extends AbstractConstraintValidatorTest */ public function testInvalidValues($value, $valueAsString) { - $constraint = new Null(array( + $constraint = new IsNull(array( 'message' => 'myMessage', )); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsTrueValidatorTest.php similarity index 72% rename from src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php rename to src/Symfony/Component/Validator/Tests/Constraints/IsTrueValidatorTest.php index 2cdc703183..a4f0a4aaeb 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsTrueValidatorTest.php @@ -11,11 +11,11 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Component\Validator\Constraints\True; -use Symfony\Component\Validator\Constraints\TrueValidator; +use Symfony\Component\Validator\Constraints\IsTrue; +use Symfony\Component\Validator\Constraints\IsTrueValidator; use Symfony\Component\Validator\Validation; -class TrueValidatorTest extends AbstractConstraintValidatorTest +class IsTrueValidatorTest extends AbstractConstraintValidatorTest { protected function getApiVersion() { @@ -24,26 +24,26 @@ class TrueValidatorTest extends AbstractConstraintValidatorTest protected function createValidator() { - return new TrueValidator(); + return new IsTrueValidator(); } public function testNullIsValid() { - $this->validator->validate(null, new True()); + $this->validator->validate(null, new IsTrue()); $this->assertNoViolation(); } public function testTrueIsValid() { - $this->validator->validate(true, new True()); + $this->validator->validate(true, new IsTrue()); $this->assertNoViolation(); } public function testFalseIsInvalid() { - $constraint = new True(array( + $constraint = new IsTrue(array( 'message' => 'myMessage', )); diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/Entity.php b/src/Symfony/Component/Validator/Tests/Fixtures/Entity.php index 2230d30424..526ecc5f5c 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/Entity.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/Entity.php @@ -64,7 +64,7 @@ class Entity extends EntityParent implements EntityInterface } /** - * @Assert\True + * @Assert\IsTrue */ public function isValid() { @@ -72,7 +72,7 @@ class Entity extends EntityParent implements EntityInterface } /** - * @Assert\True + * @Assert\IsTrue */ public function hasPermissions() { diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php index 8da207ff9d..5a2beff29a 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php @@ -18,7 +18,7 @@ use Symfony\Component\Validator\Constraints\Choice; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Range; -use Symfony\Component\Validator\Constraints\True; +use Symfony\Component\Validator\Constraints\IsTrue; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader; use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; @@ -68,8 +68,8 @@ class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase 'choices' => array('A', 'B'), ))); $expected->addGetterConstraint('lastName', new NotNull()); - $expected->addGetterConstraint('valid', new True()); - $expected->addGetterConstraint('permissions', new True()); + $expected->addGetterConstraint('valid', new IsTrue()); + $expected->addGetterConstraint('permissions', new IsTrue()); // load reflection class so that the comparison passes $expected->getReflectionClass(); @@ -137,8 +137,8 @@ class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase 'choices' => array('A', 'B'), ))); $expected->addGetterConstraint('lastName', new NotNull()); - $expected->addGetterConstraint('valid', new True()); - $expected->addGetterConstraint('permissions', new True()); + $expected->addGetterConstraint('valid', new IsTrue()); + $expected->addGetterConstraint('permissions', new IsTrue()); // load reflection class so that the comparison passes $expected->getReflectionClass(); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php index 8ab2065ae5..e6326b9a31 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php @@ -18,7 +18,7 @@ use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Constraints\Regex; -use Symfony\Component\Validator\Constraints\True; +use Symfony\Component\Validator\Constraints\IsTrue; use Symfony\Component\Validator\Exception\MappingException; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\XmlFileLoader; @@ -71,8 +71,8 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase 'choices' => array('A', 'B'), ))); $expected->addGetterConstraint('lastName', new NotNull()); - $expected->addGetterConstraint('valid', new True()); - $expected->addGetterConstraint('permissions', new True()); + $expected->addGetterConstraint('valid', new IsTrue()); + $expected->addGetterConstraint('permissions', new IsTrue()); $this->assertEquals($expected, $metadata); } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php index 806a2b049b..407e36958e 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php @@ -17,7 +17,7 @@ use Symfony\Component\Validator\Constraints\Choice; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Range; -use Symfony\Component\Validator\Constraints\True; +use Symfony\Component\Validator\Constraints\IsTrue; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\YamlFileLoader; use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; @@ -102,8 +102,8 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase 'choices' => array('A', 'B'), ))); $expected->addGetterConstraint('lastName', new NotNull()); - $expected->addGetterConstraint('valid', new True()); - $expected->addGetterConstraint('permissions', new True()); + $expected->addGetterConstraint('valid', new IsTrue()); + $expected->addGetterConstraint('permissions', new IsTrue()); $this->assertEquals($expected, $metadata); } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml b/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml index 9b637e9a42..689184ecf2 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml @@ -103,10 +103,10 @@ - + - + diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.yml b/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.yml index e96c5e0866..c39168c96c 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.yml +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.yml @@ -54,9 +54,9 @@ Symfony\Component\Validator\Tests\Fixtures\Entity: lastName: - NotNull: ~ valid: - - "True": ~ + - "IsTrue": ~ permissions: - - "True": ~ + - "IsTrue": ~ Symfony\Component\Validator\Tests\Fixtures\GroupSequenceProviderEntity: group_sequence_provider: true