From 46f0393f7016b55d725be8f2927a07ff84455ea2 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 9 Feb 2012 17:54:30 +0100 Subject: [PATCH] [Validator] Removed return value from ConstraintValidatorInterface::isValid() --- .../Constraints/UniqueEntityValidator.php | 8 +-- .../Constraint/UserPasswordValidator.php | 4 -- .../ConstraintValidatorInterface.php | 2 - .../Validator/Constraints/AllValidator.php | 8 +-- .../Validator/Constraints/BlankValidator.php | 8 +-- .../Constraints/CallbackValidator.php | 13 ++-- .../Validator/Constraints/ChoiceValidator.php | 16 ++--- .../Constraints/CollectionValidator.php | 12 +--- .../Constraints/CountryValidator.php | 10 +--- .../Constraints/DateTimeValidator.php | 2 + .../Validator/Constraints/DateValidator.php | 16 ++--- .../Validator/Constraints/EmailValidator.php | 10 +--- .../Validator/Constraints/FalseValidator.php | 14 ++--- .../Validator/Constraints/FileValidator.php | 32 +++++----- .../Validator/Constraints/ImageValidator.php | 27 ++++----- .../Validator/Constraints/IpValidator.php | 10 +--- .../Constraints/LanguageValidator.php | 10 +--- .../Validator/Constraints/LocaleValidator.php | 10 +--- .../Constraints/MaxLengthValidator.php | 10 +--- .../Validator/Constraints/MaxValidator.php | 12 ++-- .../Constraints/MinLengthValidator.php | 10 +--- .../Validator/Constraints/MinValidator.php | 12 ++-- .../Constraints/NotBlankValidator.php | 8 +-- .../Constraints/NotNullValidator.php | 8 +-- .../Validator/Constraints/NullValidator.php | 8 +-- .../Validator/Constraints/RegexValidator.php | 10 +--- .../Constraints/SizeLengthValidator.php | 12 +--- .../Validator/Constraints/SizeValidator.php | 12 ++-- .../Validator/Constraints/TimeValidator.php | 16 ++--- .../Validator/Constraints/TrueValidator.php | 4 +- .../Validator/Constraints/TypeValidator.php | 14 ++--- .../Validator/Constraints/UrlValidator.php | 10 +--- .../Tests/Constraints/AllValidatorTest.php | 9 ++- .../Tests/Constraints/BlankValidatorTest.php | 6 +- .../Constraints/CallbackValidatorTest.php | 12 ++-- .../Tests/Constraints/ChoiceValidatorTest.php | 34 +++++------ .../Constraints/CollectionValidatorTest.php | 60 +++++++++---------- .../Constraints/CountryValidatorTest.php | 8 +-- .../Constraints/DateTimeValidatorTest.php | 10 ++-- .../Tests/Constraints/DateValidatorTest.php | 10 ++-- .../Tests/Constraints/EmailValidatorTest.php | 8 +-- .../Tests/Constraints/FalseValidatorTest.php | 6 +- .../Constraints/FileValidatorPathTest.php | 2 +- .../Tests/Constraints/FileValidatorTest.php | 24 ++++---- .../Tests/Constraints/ImageValidatorTest.php | 16 ++--- .../Tests/Constraints/IpValidatorTest.php | 40 ++++++------- .../Constraints/LanguageValidatorTest.php | 8 +-- .../Tests/Constraints/LocaleValidatorTest.php | 8 +-- .../Constraints/MaxLengthValidatorTest.php | 8 +-- .../Tests/Constraints/MaxValidatorTest.php | 6 +- .../Constraints/MinLengthValidatorTest.php | 8 +-- .../Tests/Constraints/MinValidatorTest.php | 6 +- .../Constraints/NotBlankValidatorTest.php | 10 ++-- .../Constraints/NotNullValidatorTest.php | 4 +- .../Tests/Constraints/NullValidatorTest.php | 4 +- .../Tests/Constraints/RegexValidatorTest.php | 8 +-- .../Constraints/SizeLengthValidatorTest.php | 14 ++--- .../Tests/Constraints/SizeValidatorTest.php | 10 ++-- .../Tests/Constraints/TimeValidatorTest.php | 10 ++-- .../Tests/Constraints/TrueValidatorTest.php | 6 +- .../Tests/Constraints/TypeValidatorTest.php | 10 ++-- .../Tests/Constraints/UrlValidatorTest.php | 10 ++-- .../Tests/Fixtures/ConstraintAValidator.php | 4 +- .../Fixtures/FailingConstraintValidator.php | 2 +- 64 files changed, 302 insertions(+), 437 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index dc4e125e9a39..10ecbd88fbdb 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -40,8 +40,6 @@ public function __construct(ManagerRegistry $registry) /** * @param object $entity * @param Constraint $constraint - * - * @return bool */ public function isValid($entity, Constraint $constraint) { @@ -74,7 +72,7 @@ public function isValid($entity, Constraint $constraint) $criteria[$fieldName] = $class->reflFields[$fieldName]->getValue($entity); if (null === $criteria[$fieldName]) { - return true; + return; } if ($class->hasAssociation($fieldName)) { @@ -113,11 +111,9 @@ public function isValid($entity, Constraint $constraint) * unique. */ if (0 === count($result) || (1 === count($result) && $entity === ($result instanceof \Iterator ? $result->current() : current($result)))) { - return true; + return; } $this->context->addViolationAtSubPath($fields[0], $constraint->message, array(), $criteria[$fields[0]]); - - return true; // all true, we added the violation already! } } diff --git a/src/Symfony/Bundle/SecurityBundle/Validator/Constraint/UserPasswordValidator.php b/src/Symfony/Bundle/SecurityBundle/Validator/Constraint/UserPasswordValidator.php index e817886090e5..355fb74a3eb6 100644 --- a/src/Symfony/Bundle/SecurityBundle/Validator/Constraint/UserPasswordValidator.php +++ b/src/Symfony/Bundle/SecurityBundle/Validator/Constraint/UserPasswordValidator.php @@ -41,10 +41,6 @@ public function isValid($password, Constraint $constraint) if (!$encoder->isPasswordValid($user->getPassword(), $password, $user->getSalt())) { $this->context->addViolation($constraint->message); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/ConstraintValidatorInterface.php b/src/Symfony/Component/Validator/ConstraintValidatorInterface.php index a813a671593a..99a99ffb591b 100644 --- a/src/Symfony/Component/Validator/ConstraintValidatorInterface.php +++ b/src/Symfony/Component/Validator/ConstraintValidatorInterface.php @@ -31,8 +31,6 @@ function initialize(ExecutionContext $context); * @param mixed $value The value that should be validated * @param Constraint $constraint The constrain for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ function isValid($value, Constraint $constraint); diff --git a/src/Symfony/Component/Validator/Constraints/AllValidator.php b/src/Symfony/Component/Validator/Constraints/AllValidator.php index 4f6a2b8dd862..fb9b65f6a9c0 100644 --- a/src/Symfony/Component/Validator/Constraints/AllValidator.php +++ b/src/Symfony/Component/Validator/Constraints/AllValidator.php @@ -16,6 +16,8 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** + * @author Bernhard Schussek + * * @api */ class AllValidator extends ConstraintValidator @@ -26,14 +28,12 @@ class AllValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value) { - return true; + return; } if (!is_array($value) && !$value instanceof \Traversable) { @@ -53,7 +53,5 @@ public function isValid($value, Constraint $constraint) $walker->walkConstraint($constr, $element, $group, $propertyPath.'['.$key.']'); } } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/BlankValidator.php b/src/Symfony/Component/Validator/Constraints/BlankValidator.php index 07212eaa65ca..b57de12a9b01 100644 --- a/src/Symfony/Component/Validator/Constraints/BlankValidator.php +++ b/src/Symfony/Component/Validator/Constraints/BlankValidator.php @@ -15,6 +15,8 @@ use Symfony\Component\Validator\ConstraintValidator; /** + * @author Bernhard Schussek + * * @api */ class BlankValidator extends ConstraintValidator @@ -25,18 +27,12 @@ class BlankValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if ('' !== $value && null !== $value) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/CallbackValidator.php b/src/Symfony/Component/Validator/Constraints/CallbackValidator.php index c7a9fa286e3c..1a11f35d4207 100644 --- a/src/Symfony/Component/Validator/Constraints/CallbackValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CallbackValidator.php @@ -19,7 +19,7 @@ /** * Validator for Callback constraint * - * @author Bernhard Schussek + * @author Bernhard Schussek * * @api */ @@ -31,14 +31,12 @@ class CallbackValidator extends ConstraintValidator * @param mixed $object The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($object, Constraint $constraint) { if (null === $object) { - return true; + return; } // has to be an array so that we can differentiate between callables @@ -48,7 +46,6 @@ public function isValid($object, Constraint $constraint) } $methods = $constraint->methods; - $success = true; foreach ($methods as $method) { if (is_array($method) || $method instanceof \Closure) { @@ -56,16 +53,14 @@ public function isValid($object, Constraint $constraint) throw new ConstraintDefinitionException(sprintf('"%s::%s" targeted by Callback constraint is not a valid callable', $method[0], $method[1])); } - $success = call_user_func($method, $object, $this->context) && $success; + call_user_func($method, $object, $this->context); } else { if (!method_exists($object, $method)) { throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist', $method)); } - $success = $object->$method($this->context) && $success; + $object->$method($this->context); } } - - return $success; } } diff --git a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php index 7dabfd7ca3d0..9976ae5ab4ba 100644 --- a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php @@ -21,7 +21,7 @@ * * @author Fabien Potencier * @author Florian Eckerstorfer - * @author Bernhard Schussek + * @author Bernhard Schussek * * @api */ @@ -33,8 +33,6 @@ class ChoiceValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) @@ -44,7 +42,7 @@ public function isValid($value, Constraint $constraint) } if (null === $value) { - return true; + return; } if ($constraint->multiple && !is_array($value)) { @@ -67,8 +65,6 @@ public function isValid($value, Constraint $constraint) foreach ($value as $_value) { if (!in_array($_value, $choices, $constraint->strict)) { $this->context->addViolation($constraint->multipleMessage, array('{{ value }}' => $_value)); - - return false; } } @@ -77,20 +73,16 @@ public function isValid($value, Constraint $constraint) if ($constraint->min !== null && $count < $constraint->min) { $this->context->addViolation($constraint->minMessage, array('{{ limit }}' => $constraint->min), null, (int) $constraint->min); - return false; + return; } if ($constraint->max !== null && $count > $constraint->max) { $this->context->addViolation($constraint->maxMessage, array('{{ limit }}' => $constraint->max), null, (int) $constraint->max); - return false; + return; } } elseif (!in_array($value, $choices, $constraint->strict)) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/CollectionValidator.php b/src/Symfony/Component/Validator/Constraints/CollectionValidator.php index ab537c2319d2..a80c07be4430 100644 --- a/src/Symfony/Component/Validator/Constraints/CollectionValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CollectionValidator.php @@ -18,6 +18,8 @@ use Symfony\Component\Validator\Constraints\Collection\Required; /** + * @author Bernhard Schussek + * * @api */ class CollectionValidator extends ConstraintValidator @@ -28,14 +30,12 @@ class CollectionValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value) { - return true; + return; } if (!is_array($value) && !($value instanceof \Traversable && $value instanceof \ArrayAccess)) { @@ -46,8 +46,6 @@ public function isValid($value, Constraint $constraint) $group = $this->context->getGroup(); $propertyPath = $this->context->getPropertyPath(); - $valid = true; - foreach ($constraint->fields as $field => $fieldConstraint) { if ( // bug fix issue #2779 @@ -71,7 +69,6 @@ public function isValid($value, Constraint $constraint) $this->context->addViolationAtSubPath('['.$field.']', $constraint->missingFieldsMessage, array( '{{ field }}' => $field ), null); - $valid = false; } } @@ -81,11 +78,8 @@ public function isValid($value, Constraint $constraint) $this->context->addViolationAtSubPath('['.$field.']', $constraint->extraFieldsMessage, array( '{{ field }}' => $field ), $fieldValue); - $valid = false; } } } - - return $valid; } } diff --git a/src/Symfony/Component/Validator/Constraints/CountryValidator.php b/src/Symfony/Component/Validator/Constraints/CountryValidator.php index c6de580500b3..75dbc3004bef 100644 --- a/src/Symfony/Component/Validator/Constraints/CountryValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CountryValidator.php @@ -18,7 +18,7 @@ /** * Validates whether a value is a valid country code * - * @author Bernhard Schussek + * @author Bernhard Schussek * * @api */ @@ -30,14 +30,12 @@ class CountryValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value || '' === $value) { - return true; + return; } if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { @@ -48,10 +46,6 @@ public function isValid($value, Constraint $constraint) if (!in_array($value, \Symfony\Component\Locale\Locale::getCountries())) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php b/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php index 1456db0fa498..49e04b94f2bd 100644 --- a/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php @@ -12,6 +12,8 @@ namespace Symfony\Component\Validator\Constraints; /** + * @author Bernhard Schussek + * * @api */ class DateTimeValidator extends DateValidator diff --git a/src/Symfony/Component/Validator/Constraints/DateValidator.php b/src/Symfony/Component/Validator/Constraints/DateValidator.php index db4ef7c822ad..2a132ee99a8c 100644 --- a/src/Symfony/Component/Validator/Constraints/DateValidator.php +++ b/src/Symfony/Component/Validator/Constraints/DateValidator.php @@ -16,6 +16,8 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** + * @author Bernhard Schussek + * * @api */ class DateValidator extends ConstraintValidator @@ -28,18 +30,12 @@ class DateValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { - if (null === $value || '' === $value) { - return true; - } - - if ($value instanceof \DateTime) { - return true; + if (null === $value || '' === $value || $value instanceof \DateTime) { + return; } if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { @@ -50,10 +46,6 @@ public function isValid($value, Constraint $constraint) if (!preg_match(static::PATTERN, $value, $matches) || !checkdate($matches[2], $matches[3], $matches[1])) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php index a55c137e764d..4d2b1e0860b3 100644 --- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -16,6 +16,8 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** + * @author Bernhard Schussek + * * @api */ class EmailValidator extends ConstraintValidator @@ -26,14 +28,12 @@ class EmailValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value || '' === $value) { - return true; + return; } if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { @@ -61,11 +61,7 @@ public function isValid($value, Constraint $constraint) if (!$valid) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); - - return false; } - - return true; } /** diff --git a/src/Symfony/Component/Validator/Constraints/FalseValidator.php b/src/Symfony/Component/Validator/Constraints/FalseValidator.php index f473f7a19ad4..57919b65f6bd 100644 --- a/src/Symfony/Component/Validator/Constraints/FalseValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FalseValidator.php @@ -15,6 +15,8 @@ use Symfony\Component\Validator\ConstraintValidator; /** + * @author Bernhard Schussek + * * @api */ class FalseValidator extends ConstraintValidator @@ -25,22 +27,14 @@ class FalseValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { - if (null === $value) { - return true; - } - - if (false === $value || 0 === $value || '0' === $value) { - return true; + if (null === $value || false === $value || 0 === $value || '0' === $value) { + return; } $this->context->addViolation($constraint->message); - - return false; } } diff --git a/src/Symfony/Component/Validator/Constraints/FileValidator.php b/src/Symfony/Component/Validator/Constraints/FileValidator.php index 05d3e3e9836c..a766250b83e0 100644 --- a/src/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FileValidator.php @@ -19,6 +19,8 @@ use Symfony\Component\HttpFoundation\File\UploadedFile; /** + * @author Bernhard Schussek + * * @api */ class FileValidator extends ConstraintValidator @@ -29,14 +31,12 @@ class FileValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value || '' === $value) { - return true; + return; } if ($value instanceof UploadedFile && !$value->isValid()) { @@ -46,35 +46,35 @@ public function isValid($value, Constraint $constraint) $maxSize = $constraint->maxSize ? min($maxSize, $constraint->maxSize) : $maxSize; $this->context->addViolation($constraint->uploadIniSizeErrorMessage, array('{{ limit }}' => $maxSize.' bytes')); - return false; + return; case UPLOAD_ERR_FORM_SIZE: $this->context->addViolation($constraint->uploadFormSizeErrorMessage); - return false; + return; case UPLOAD_ERR_PARTIAL: $this->context->addViolation($constraint->uploadPartialErrorMessage); - return false; + return; case UPLOAD_ERR_NO_FILE: $this->context->addViolation($constraint->uploadNoFileErrorMessage); - return false; + return; case UPLOAD_ERR_NO_TMP_DIR: $this->context->addViolation($constraint->uploadNoTmpDirErrorMessage); - return false; + return; case UPLOAD_ERR_CANT_WRITE: $this->context->addViolation($constraint->uploadCantWriteErrorMessage); - return false; + return; case UPLOAD_ERR_EXTENSION: $this->context->addViolation($constraint->uploadExtensionErrorMessage); - return false; + return; default: $this->context->addViolation($constraint->uploadErrorMessage); - return false; + return; } } @@ -87,13 +87,13 @@ public function isValid($value, Constraint $constraint) if (!is_file($path)) { $this->context->addViolation($constraint->notFoundMessage, array('{{ file }}' => $path)); - return false; + return; } if (!is_readable($path)) { $this->context->addViolation($constraint->notReadableMessage, array('{{ file }}' => $path)); - return false; + return; } if ($constraint->maxSize) { @@ -120,7 +120,7 @@ public function isValid($value, Constraint $constraint) '{{ file }}' => $path, )); - return false; + return; } } @@ -153,11 +153,7 @@ public function isValid($value, Constraint $constraint) '{{ types }}' => '"'.implode('", "', $mimeTypes) .'"', '{{ file }}' => $path, )); - - return false; } } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/ImageValidator.php b/src/Symfony/Component/Validator/Constraints/ImageValidator.php index f91113c0fa31..5708cb30de09 100644 --- a/src/Symfony/Component/Validator/Constraints/ImageValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ImageValidator.php @@ -24,25 +24,26 @@ class ImageValidator extends FileValidator { public function isValid($value, Constraint $constraint) { - $isValid = parent::isValid($value, $constraint); - if (!$isValid) { - return false; - } + $violations = count($this->context->getViolations()); + + parent::isValid($value, $constraint); + + $isValid = count($this->context->getViolations()) === $violations; - if (null === $value || '' === $value) { - return true; + if (!$isValid || null === $value || '' === $value) { + return; } if (null === $constraint->minWidth && null === $constraint->maxWidth && null === $constraint->minHeight && null === $constraint->maxHeight) { - return true; + return; } $size = @getimagesize($value); if (empty($size) || ($size[0] === 0) || ($size[1] === 0)) { $this->context->addViolation($constraint->sizeNotDetectedMessage); - return false; + return; } $width = $size[0]; @@ -59,7 +60,7 @@ public function isValid($value, Constraint $constraint) '{{ min_width }}' => $constraint->minWidth )); - return false; + return; } } @@ -74,7 +75,7 @@ public function isValid($value, Constraint $constraint) '{{ max_width }}' => $constraint->maxWidth )); - return false; + return; } } @@ -89,7 +90,7 @@ public function isValid($value, Constraint $constraint) '{{ min_height }}' => $constraint->minHeight )); - return false; + return; } } @@ -103,11 +104,7 @@ public function isValid($value, Constraint $constraint) '{{ height }}' => $height, '{{ max_height }}' => $constraint->maxHeight )); - - return false; } } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/IpValidator.php b/src/Symfony/Component/Validator/Constraints/IpValidator.php index 4bb3fe547a9c..4195d3b1db7a 100644 --- a/src/Symfony/Component/Validator/Constraints/IpValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IpValidator.php @@ -18,7 +18,7 @@ /** * Validates whether a value is a valid IP address * - * @author Bernhard Schussek + * @author Bernhard Schussek * @author Joseph Bielawski * * @api @@ -31,14 +31,12 @@ class IpValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value || '' === $value) { - return true; + return; } if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { @@ -99,10 +97,6 @@ public function isValid($value, Constraint $constraint) if (!filter_var($value, FILTER_VALIDATE_IP, $flag)) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/LanguageValidator.php b/src/Symfony/Component/Validator/Constraints/LanguageValidator.php index e5ee7ff6c048..12337b9704e6 100644 --- a/src/Symfony/Component/Validator/Constraints/LanguageValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LanguageValidator.php @@ -18,7 +18,7 @@ /** * Validates whether a value is a valid language code * - * @author Bernhard Schussek + * @author Bernhard Schussek * * @api */ @@ -30,14 +30,12 @@ class LanguageValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value || '' === $value) { - return true; + return; } if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { @@ -48,10 +46,6 @@ public function isValid($value, Constraint $constraint) if (!in_array($value, \Symfony\Component\Locale\Locale::getLanguages())) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/LocaleValidator.php b/src/Symfony/Component/Validator/Constraints/LocaleValidator.php index 4ad75447c0a4..639fbaa51f5e 100644 --- a/src/Symfony/Component/Validator/Constraints/LocaleValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LocaleValidator.php @@ -18,7 +18,7 @@ /** * Validates whether a value is a valid locale code * - * @author Bernhard Schussek + * @author Bernhard Schussek * * @api */ @@ -30,14 +30,12 @@ class LocaleValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value || '' === $value) { - return true; + return; } if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { @@ -48,10 +46,6 @@ public function isValid($value, Constraint $constraint) if (!in_array($value, \Symfony\Component\Locale\Locale::getLocales())) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/MaxLengthValidator.php b/src/Symfony/Component/Validator/Constraints/MaxLengthValidator.php index 686c603f19f1..5425086c0703 100644 --- a/src/Symfony/Component/Validator/Constraints/MaxLengthValidator.php +++ b/src/Symfony/Component/Validator/Constraints/MaxLengthValidator.php @@ -16,6 +16,8 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** + * @author Bernhard Schussek + * * @api */ class MaxLengthValidator extends ConstraintValidator @@ -26,14 +28,12 @@ class MaxLengthValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value || '' === $value) { - return true; + return; } if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { @@ -55,10 +55,6 @@ public function isValid($value, Constraint $constraint) '{{ value }}' => $value, '{{ limit }}' => $constraint->limit, ), null, (int) $constraint->limit); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/MaxValidator.php b/src/Symfony/Component/Validator/Constraints/MaxValidator.php index 018f4d0c47d3..67256ed405ab 100644 --- a/src/Symfony/Component/Validator/Constraints/MaxValidator.php +++ b/src/Symfony/Component/Validator/Constraints/MaxValidator.php @@ -15,6 +15,8 @@ use Symfony\Component\Validator\ConstraintValidator; /** + * @author Bernhard Schussek + * * @api */ class MaxValidator extends ConstraintValidator @@ -25,14 +27,12 @@ class MaxValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constrain for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value) { - return true; + return; } if (!is_numeric($value)) { @@ -41,7 +41,7 @@ public function isValid($value, Constraint $constraint) '{{ limit }}' => $constraint->limit, )); - return false; + return; } if ($value > $constraint->limit) { @@ -49,10 +49,6 @@ public function isValid($value, Constraint $constraint) '{{ value }}' => $value, '{{ limit }}' => $constraint->limit, )); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/MinLengthValidator.php b/src/Symfony/Component/Validator/Constraints/MinLengthValidator.php index 6b3f13ab77d8..bc0da32fa0e4 100644 --- a/src/Symfony/Component/Validator/Constraints/MinLengthValidator.php +++ b/src/Symfony/Component/Validator/Constraints/MinLengthValidator.php @@ -16,6 +16,8 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** + * @author Bernhard Schussek + * * @api */ class MinLengthValidator extends ConstraintValidator @@ -26,14 +28,12 @@ class MinLengthValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value || '' === $value) { - return true; + return; } if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { @@ -55,10 +55,6 @@ public function isValid($value, Constraint $constraint) '{{ value }}' => $value, '{{ limit }}' => $constraint->limit, ), null, (int) $constraint->limit); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/MinValidator.php b/src/Symfony/Component/Validator/Constraints/MinValidator.php index 24e030edbff1..1e059dd93b05 100644 --- a/src/Symfony/Component/Validator/Constraints/MinValidator.php +++ b/src/Symfony/Component/Validator/Constraints/MinValidator.php @@ -15,6 +15,8 @@ use Symfony\Component\Validator\ConstraintValidator; /** + * @author Bernhard Schussek + * * @api */ class MinValidator extends ConstraintValidator @@ -25,14 +27,12 @@ class MinValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value) { - return true; + return; } if (!is_numeric($value)) { @@ -41,7 +41,7 @@ public function isValid($value, Constraint $constraint) '{{ limit }}' => $constraint->limit, )); - return false; + return; } if ($value < $constraint->limit) { @@ -49,10 +49,6 @@ public function isValid($value, Constraint $constraint) '{{ value }}' => $value, '{{ limit }}' => $constraint->limit, )); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/NotBlankValidator.php b/src/Symfony/Component/Validator/Constraints/NotBlankValidator.php index 5fe90ce94db4..524bf345d7a4 100644 --- a/src/Symfony/Component/Validator/Constraints/NotBlankValidator.php +++ b/src/Symfony/Component/Validator/Constraints/NotBlankValidator.php @@ -15,6 +15,8 @@ use Symfony\Component\Validator\ConstraintValidator; /** + * @author Bernhard Schussek + * * @api */ class NotBlankValidator extends ConstraintValidator @@ -25,18 +27,12 @@ class NotBlankValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (false === $value || (empty($value) && '0' != $value)) { $this->context->addViolation($constraint->message); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/NotNullValidator.php b/src/Symfony/Component/Validator/Constraints/NotNullValidator.php index 0c8759cefcf6..2a85c9f8e1ac 100644 --- a/src/Symfony/Component/Validator/Constraints/NotNullValidator.php +++ b/src/Symfony/Component/Validator/Constraints/NotNullValidator.php @@ -15,6 +15,8 @@ use Symfony\Component\Validator\ConstraintValidator; /** + * @author Bernhard Schussek + * * @api */ class NotNullValidator extends ConstraintValidator @@ -25,18 +27,12 @@ class NotNullValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value) { $this->context->addViolation($constraint->message); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/NullValidator.php b/src/Symfony/Component/Validator/Constraints/NullValidator.php index dc04f9cbabf6..731b06c1f33b 100644 --- a/src/Symfony/Component/Validator/Constraints/NullValidator.php +++ b/src/Symfony/Component/Validator/Constraints/NullValidator.php @@ -15,6 +15,8 @@ use Symfony\Component\Validator\ConstraintValidator; /** + * @author Bernhard Schussek + * * @api */ class NullValidator extends ConstraintValidator @@ -25,18 +27,12 @@ class NullValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null !== $value) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/RegexValidator.php b/src/Symfony/Component/Validator/Constraints/RegexValidator.php index ebf517bf80cc..32cc37989b3b 100644 --- a/src/Symfony/Component/Validator/Constraints/RegexValidator.php +++ b/src/Symfony/Component/Validator/Constraints/RegexValidator.php @@ -18,7 +18,7 @@ /** * Validates whether a value match or not given regexp pattern * - * @author Bernhard Schussek + * @author Bernhard Schussek * @author Joseph Bielawski * * @api @@ -31,14 +31,12 @@ class RegexValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value || '' === $value) { - return true; + return; } if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { @@ -49,10 +47,6 @@ public function isValid($value, Constraint $constraint) if ($constraint->match xor preg_match($constraint->pattern, $value)) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/SizeLengthValidator.php b/src/Symfony/Component/Validator/Constraints/SizeLengthValidator.php index 100d728dc2c8..142f98311711 100644 --- a/src/Symfony/Component/Validator/Constraints/SizeLengthValidator.php +++ b/src/Symfony/Component/Validator/Constraints/SizeLengthValidator.php @@ -26,14 +26,12 @@ class SizeLengthValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value || '' === $value) { - return true; + return; } if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { @@ -56,7 +54,7 @@ public function isValid($value, Constraint $constraint) '{{ limit }}' => $constraint->max, ), null, (int) $constraint->max); - return false; + return; } if ($length > $constraint->max) { @@ -65,7 +63,7 @@ public function isValid($value, Constraint $constraint) '{{ limit }}' => $constraint->max, ), null, (int) $constraint->max); - return false; + return; } if ($length < $constraint->min) { @@ -73,10 +71,6 @@ public function isValid($value, Constraint $constraint) '{{ value }}' => $value, '{{ limit }}' => $constraint->min, ), null, (int) $constraint->min); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/SizeValidator.php b/src/Symfony/Component/Validator/Constraints/SizeValidator.php index db8bc65c6827..0993657dd621 100644 --- a/src/Symfony/Component/Validator/Constraints/SizeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/SizeValidator.php @@ -15,6 +15,8 @@ use Symfony\Component\Validator\ConstraintValidator; /** + * @author Bernhard Schussek + * * @api */ class SizeValidator extends ConstraintValidator @@ -32,7 +34,7 @@ class SizeValidator extends ConstraintValidator public function isValid($value, Constraint $constraint) { if (null === $value) { - return true; + return; } if (!is_numeric($value)) { @@ -40,7 +42,7 @@ public function isValid($value, Constraint $constraint) '{{ value }}' => $value, )); - return false; + return; } if ($value > $constraint->max) { @@ -49,7 +51,7 @@ public function isValid($value, Constraint $constraint) '{{ limit }}' => $constraint->max, )); - return false; + return; } if ($value < $constraint->min) { @@ -57,10 +59,6 @@ public function isValid($value, Constraint $constraint) '{{ value }}' => $value, '{{ limit }}' => $constraint->min, )); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/TimeValidator.php b/src/Symfony/Component/Validator/Constraints/TimeValidator.php index 6c4b8d538c87..03a33ba0c668 100644 --- a/src/Symfony/Component/Validator/Constraints/TimeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TimeValidator.php @@ -16,6 +16,8 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** + * @author Bernhard Schussek + * * @api */ class TimeValidator extends ConstraintValidator @@ -28,18 +30,12 @@ class TimeValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { - if (null === $value || '' === $value) { - return true; - } - - if ($value instanceof \DateTime) { - return true; + if (null === $value || '' === $value || $value instanceof \DateTime) { + return; } if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { @@ -50,10 +46,6 @@ public function isValid($value, Constraint $constraint) if (!preg_match(static::PATTERN, $value)) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Constraints/TrueValidator.php b/src/Symfony/Component/Validator/Constraints/TrueValidator.php index fe58c72eb571..7a4ea2595749 100644 --- a/src/Symfony/Component/Validator/Constraints/TrueValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TrueValidator.php @@ -15,6 +15,8 @@ use Symfony\Component\Validator\ConstraintValidator; /** + * @author Bernhard Schussek + * * @api */ class TrueValidator extends ConstraintValidator @@ -25,8 +27,6 @@ class TrueValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) diff --git a/src/Symfony/Component/Validator/Constraints/TypeValidator.php b/src/Symfony/Component/Validator/Constraints/TypeValidator.php index 71bbed80bd67..527258463fe6 100644 --- a/src/Symfony/Component/Validator/Constraints/TypeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TypeValidator.php @@ -15,6 +15,8 @@ use Symfony\Component\Validator\ConstraintValidator; /** + * @author Bernhard Schussek + * * @api */ class TypeValidator extends ConstraintValidator @@ -25,14 +27,12 @@ class TypeValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value) { - return true; + return; } $type = strtolower($constraint->type); @@ -41,18 +41,16 @@ public function isValid($value, Constraint $constraint) $ctypeFunction = 'ctype_'.$type; if (function_exists($isFunction) && call_user_func($isFunction, $value)) { - return true; + return; } elseif (function_exists($ctypeFunction) && call_user_func($ctypeFunction, $value)) { - return true; + return; } elseif ($value instanceof $constraint->type) { - return true; + return; } $this->context->addViolation($constraint->message, array( '{{ value }}' => is_object($value) ? get_class($value) : (is_array($value) ? 'Array' : (string) $value), '{{ type }}' => $constraint->type, )); - - return false; } } diff --git a/src/Symfony/Component/Validator/Constraints/UrlValidator.php b/src/Symfony/Component/Validator/Constraints/UrlValidator.php index 0514ce661db1..12b990d75662 100644 --- a/src/Symfony/Component/Validator/Constraints/UrlValidator.php +++ b/src/Symfony/Component/Validator/Constraints/UrlValidator.php @@ -16,6 +16,8 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** + * @author Bernhard Schussek + * * @api */ class UrlValidator extends ConstraintValidator @@ -41,14 +43,12 @@ class UrlValidator extends ConstraintValidator * @param mixed $value The value that should be validated * @param Constraint $constraint The constraint for the validation * - * @return Boolean Whether or not the value is valid - * * @api */ public function isValid($value, Constraint $constraint) { if (null === $value || '' === $value) { - return true; + return; } if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { @@ -61,10 +61,6 @@ public function isValid($value, Constraint $constraint) if (!preg_match($pattern, $value)) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); - - return false; } - - return true; } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php index 7715ef3de9c4..8022ab1002fe 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php @@ -51,7 +51,10 @@ protected function tearDown() public function testNullIsValid() { - $this->assertTrue($this->validator->isValid(null, new All(new Min(4)))); + $this->context->expects($this->never()) + ->method('addViolation'); + + $this->validator->isValid(null, new All(new Min(4))); } @@ -81,7 +84,7 @@ public function testWalkSingleConstraint($array) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($array, new All($constraint))); + $this->validator->isValid($array, new All($constraint)); } /** @@ -107,7 +110,7 @@ public function testWalkMultipleConstraints($array) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($array, new All($constraints))); + $this->validator->isValid($array, new All($constraints)); } public function getValidArguments() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php index de9f68210920..502327544ecb 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Blank())); + $this->validator->isValid(null, new Blank()); } public function testBlankIsValid() @@ -45,7 +45,7 @@ public function testBlankIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new Blank())); + $this->validator->isValid('', new Blank()); } /** @@ -63,7 +63,7 @@ public function testInvalidValues($value) '{{ value }}' => $value, )); - $this->assertFalse($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getInvalidValues() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php index a6c1d3d144ff..3d1b41931516 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php @@ -65,7 +65,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Callback(array('foo')))); + $this->validator->isValid(null, new Callback(array('foo'))); } public function testCallbackSingleMethod() @@ -79,7 +79,7 @@ public function testCallbackSingleMethod() '{{ value }}' => 'foobar', )); - $this->assertFalse($this->validator->isValid($object, $constraint)); + $this->validator->isValid($object, $constraint); } public function testCallbackSingleStaticMethod() @@ -92,9 +92,9 @@ public function testCallbackSingleStaticMethod() '{{ value }}' => 'foobar', )); - $this->assertFalse($this->validator->isValid($object, new Callback(array( + $this->validator->isValid($object, new Callback(array( array(__CLASS__.'_Class', 'validateStatic') - )))); + ))); } public function testCallbackMultipleMethods() @@ -113,9 +113,9 @@ public function testCallbackMultipleMethods() )); - $this->assertFalse($this->validator->isValid($object, new Callback(array( + $this->validator->isValid($object, new Callback(array( 'validateOne', 'validateTwo' - )))); + ))); } /** diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php index 50b7c6a5c9f2..851e2ed21f64 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php @@ -66,7 +66,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Choice(array('choices' => array('foo', 'bar'))))); + $this->validator->isValid(null, new Choice(array('choices' => array('foo', 'bar')))); } /** @@ -92,7 +92,7 @@ public function testValidChoiceArray() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('bar', $constraint)); + $this->validator->isValid('bar', $constraint); } public function testValidChoiceCallbackFunction() @@ -102,7 +102,7 @@ public function testValidChoiceCallbackFunction() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('bar', $constraint)); + $this->validator->isValid('bar', $constraint); } public function testValidChoiceCallbackClosure() @@ -114,7 +114,7 @@ public function testValidChoiceCallbackClosure() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('bar', $constraint)); + $this->validator->isValid('bar', $constraint); } public function testValidChoiceCallbackStaticMethod() @@ -124,7 +124,7 @@ public function testValidChoiceCallbackStaticMethod() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('bar', $constraint)); + $this->validator->isValid('bar', $constraint); } public function testValidChoiceCallbackContextMethod() @@ -134,7 +134,7 @@ public function testValidChoiceCallbackContextMethod() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('bar', $constraint)); + $this->validator->isValid('bar', $constraint); } public function testMultipleChoices() @@ -147,7 +147,7 @@ public function testMultipleChoices() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(array('baz', 'bar'), $constraint)); + $this->validator->isValid(array('baz', 'bar'), $constraint); } public function testInvalidChoice() @@ -163,7 +163,7 @@ public function testInvalidChoice() '{{ value }}' => 'baz', ), null, null); - $this->assertFalse($this->validator->isValid('baz', $constraint)); + $this->validator->isValid('baz', $constraint); } public function testInvalidChoiceMultiple() @@ -180,7 +180,7 @@ public function testInvalidChoiceMultiple() '{{ value }}' => 'baz', )); - $this->assertFalse($this->validator->isValid(array('foo', 'baz'), $constraint)); + $this->validator->isValid(array('foo', 'baz'), $constraint); } public function testTooFewChoices() @@ -198,7 +198,7 @@ public function testTooFewChoices() '{{ limit }}' => 2, ), null, 2); - $this->assertFalse($this->validator->isValid(array('foo'), $constraint)); + $this->validator->isValid(array('foo'), $constraint); } public function testTooManyChoices() @@ -216,7 +216,7 @@ public function testTooManyChoices() '{{ limit }}' => 2, ), null, 2); - $this->assertFalse($this->validator->isValid(array('foo', 'bar', 'moo'), $constraint)); + $this->validator->isValid(array('foo', 'bar', 'moo'), $constraint); } public function testNonStrict() @@ -229,8 +229,8 @@ public function testNonStrict() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('2', $constraint)); - $this->assertTrue($this->validator->isValid(2, $constraint)); + $this->validator->isValid('2', $constraint); + $this->validator->isValid(2, $constraint); } public function testStrictAllowsExactValue() @@ -243,7 +243,7 @@ public function testStrictAllowsExactValue() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(2, $constraint)); + $this->validator->isValid(2, $constraint); } public function testStrictDisallowsDifferentType() @@ -260,7 +260,7 @@ public function testStrictDisallowsDifferentType() '{{ value }}' => '2', )); - $this->assertFalse($this->validator->isValid('2', $constraint)); + $this->validator->isValid('2', $constraint); } public function testNonStrictWithMultipleChoices() @@ -274,7 +274,7 @@ public function testNonStrictWithMultipleChoices() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(array('2', 3), $constraint)); + $this->validator->isValid(array('2', 3), $constraint); } public function testStrictWithMultipleChoices() @@ -292,6 +292,6 @@ public function testStrictWithMultipleChoices() '{{ value }}' => '3', )); - $this->assertFalse($this->validator->isValid(array(2, '3'), $constraint)); + $this->validator->isValid(array(2, '3'), $constraint); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php index b9b5eec61c93..d2495004e1e0 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php @@ -58,9 +58,9 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolationAtSubPath'); - $this->assertTrue($this->validator->isValid(null, new Collection(array('fields' => array( + $this->validator->isValid(null, new Collection(array('fields' => array( 'foo' => new Min(4), - ))))); + )))); } public function testFieldsAsDefaultOption() @@ -70,9 +70,9 @@ public function testFieldsAsDefaultOption() $this->context->expects($this->never()) ->method('addViolationAtSubPath'); - $this->assertTrue($this->validator->isValid($data, new Collection(array( + $this->validator->isValid($data, new Collection(array( 'foo' => new Min(4), - )))); + ))); } /** @@ -106,12 +106,12 @@ public function testWalkSingleConstraint() $this->context->expects($this->never()) ->method('addViolationAtSubPath'); - $this->assertTrue($this->validator->isValid($data, new Collection(array( + $this->validator->isValid($data, new Collection(array( 'fields' => array( 'foo' => $constraint, 'bar' => $constraint, ), - )))); + ))); } public function testWalkMultipleConstraints() @@ -140,12 +140,12 @@ public function testWalkMultipleConstraints() $this->context->expects($this->never()) ->method('addViolationAtSubPath'); - $this->assertTrue($this->validator->isValid($data, new Collection(array( + $this->validator->isValid($data, new Collection(array( 'fields' => array( 'foo' => $constraints, 'bar' => $constraints, ) - )))); + ))); } public function testExtraFieldsDisallowed() @@ -161,12 +161,12 @@ public function testExtraFieldsDisallowed() '{{ field }}' => 'baz' )); - $this->assertFalse($this->validator->isValid($data, new Collection(array( + $this->validator->isValid($data, new Collection(array( 'fields' => array( 'foo' => new Min(4), ), 'extraFieldsMessage' => 'myMessage', - )))); + ))); } // bug fix @@ -185,7 +185,7 @@ public function testNullNotConsideredExtraField() $this->context->expects($this->never()) ->method('addViolationAtSubPath'); - $this->assertTrue($this->validator->isValid($data, $constraint)); + $this->validator->isValid($data, $constraint); } public function testExtraFieldsAllowed() @@ -205,7 +205,7 @@ public function testExtraFieldsAllowed() $this->context->expects($this->never()) ->method('addViolationAtSubPath'); - $this->assertTrue($this->validator->isValid($data, $constraint)); + $this->validator->isValid($data, $constraint); } public function testMissingFieldsDisallowed() @@ -225,7 +225,7 @@ public function testMissingFieldsDisallowed() '{{ field }}' => 'foo', )); - $this->assertFalse($this->validator->isValid($data, $constraint)); + $this->validator->isValid($data, $constraint); } public function testMissingFieldsAllowed() @@ -242,7 +242,7 @@ public function testMissingFieldsAllowed() $this->context->expects($this->never()) ->method('addViolationAtSubPath'); - $this->assertTrue($this->validator->isValid($data, $constraint)); + $this->validator->isValid($data, $constraint); } public function testOptionalFieldPresent() @@ -254,9 +254,9 @@ public function testOptionalFieldPresent() $this->context->expects($this->never()) ->method('addViolationAtSubPath'); - $this->assertTrue($this->validator->isValid($data, new Collection(array( + $this->validator->isValid($data, new Collection(array( 'foo' => new Optional(), - )))); + ))); } public function testOptionalFieldNotPresent() @@ -266,9 +266,9 @@ public function testOptionalFieldNotPresent() $this->context->expects($this->never()) ->method('addViolationAtSubPath'); - $this->assertTrue($this->validator->isValid($data, new Collection(array( + $this->validator->isValid($data, new Collection(array( 'foo' => new Optional(), - )))); + ))); } public function testOptionalFieldSingleConstraint() @@ -288,9 +288,9 @@ public function testOptionalFieldSingleConstraint() $data = $this->prepareTestData($array); - $this->assertTrue($this->validator->isValid($data, new Collection(array( + $this->validator->isValid($data, new Collection(array( 'foo' => new Optional($constraint), - )))); + ))); } public function testOptionalFieldMultipleConstraints() @@ -315,9 +315,9 @@ public function testOptionalFieldMultipleConstraints() $data = $this->prepareTestData($array); - $this->assertTrue($this->validator->isValid($data, new Collection(array( + $this->validator->isValid($data, new Collection(array( 'foo' => new Optional($constraints), - )))); + ))); } public function testRequiredFieldPresent() @@ -329,9 +329,9 @@ public function testRequiredFieldPresent() $this->context->expects($this->never()) ->method('addViolationAtSubPath'); - $this->assertTrue($this->validator->isValid($data, new Collection(array( + $this->validator->isValid($data, new Collection(array( 'foo' => new Required(), - )))); + ))); } public function testRequiredFieldNotPresent() @@ -344,12 +344,12 @@ public function testRequiredFieldNotPresent() '{{ field }}' => 'foo', )); - $this->assertFalse($this->validator->isValid($data, new Collection(array( + $this->validator->isValid($data, new Collection(array( 'fields' => array( 'foo' => new Required(), ), 'missingFieldsMessage' => 'myMessage', - )))); + ))); } public function testRequiredFieldSingleConstraint() @@ -369,9 +369,9 @@ public function testRequiredFieldSingleConstraint() $data = $this->prepareTestData($array); - $this->assertTrue($this->validator->isValid($data, new Collection(array( + $this->validator->isValid($data, new Collection(array( 'foo' => new Required($constraint), - )))); + ))); } public function testRequiredFieldMultipleConstraints() @@ -396,9 +396,9 @@ public function testRequiredFieldMultipleConstraints() $data = $this->prepareTestData($array); - $this->assertTrue($this->validator->isValid($array, new Collection(array( + $this->validator->isValid($array, new Collection(array( 'foo' => new Required($constraints), - )))); + ))); } public function testObjectShouldBeLeftUnchanged() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php index 90782b5401e2..5345c698df10 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php @@ -39,7 +39,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Country())); + $this->validator->isValid(null, new Country()); } public function testEmptyStringIsValid() @@ -47,7 +47,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new Country())); + $this->validator->isValid('', new Country()); } /** @@ -70,7 +70,7 @@ public function testValidCountries($country) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($country, new Country())); + $this->validator->isValid($country, new Country()); } public function getValidCountries() @@ -101,7 +101,7 @@ public function testInvalidCountries($country) '{{ value }}' => $country, )); - $this->assertFalse($this->validator->isValid($country, $constraint)); + $this->validator->isValid($country, $constraint); } public function getInvalidCountries() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php index d47238a9b454..3153caa10e9a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new DateTime())); + $this->validator->isValid(null, new DateTime()); } public function testEmptyStringIsValid() @@ -45,7 +45,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new DateTime())); + $this->validator->isValid('', new DateTime()); } public function testDateTimeClassIsValid() @@ -53,7 +53,7 @@ public function testDateTimeClassIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(new \DateTime(), new DateTime())); + $this->validator->isValid(new \DateTime(), new DateTime()); } /** @@ -72,7 +72,7 @@ public function testValidDateTimes($dateTime) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($dateTime, new DateTime())); + $this->validator->isValid($dateTime, new DateTime()); } public function getValidDateTimes() @@ -99,7 +99,7 @@ public function testInvalidDateTimes($dateTime) '{{ value }}' => $dateTime, )); - $this->assertFalse($this->validator->isValid($dateTime, $constraint)); + $this->validator->isValid($dateTime, $constraint); } public function getInvalidDateTimes() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php index 2305039e6cb7..5b34d461d86f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Date())); + $this->validator->isValid(null, new Date()); } public function testEmptyStringIsValid() @@ -45,7 +45,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new Date())); + $this->validator->isValid('', new Date()); } public function testDateTimeClassIsValid() @@ -53,7 +53,7 @@ public function testDateTimeClassIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(new \DateTime(), new Date())); + $this->validator->isValid(new \DateTime(), new Date()); } /** @@ -72,7 +72,7 @@ public function testValidDates($date) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($date, new Date())); + $this->validator->isValid($date, new Date()); } public function getValidDates() @@ -99,7 +99,7 @@ public function testInvalidDates($date) '{{ value }}' => $date, )); - $this->assertFalse($this->validator->isValid($date, $constraint)); + $this->validator->isValid($date, $constraint); } public function getInvalidDates() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index 1e4e2a10abf6..c5c8a97a93da 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Email())); + $this->validator->isValid(null, new Email()); } public function testEmptyStringIsValid() @@ -45,7 +45,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new Email())); + $this->validator->isValid('', new Email()); } /** @@ -64,7 +64,7 @@ public function testValidEmails($email) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($email, new Email())); + $this->validator->isValid($email, new Email()); } public function getValidEmails() @@ -91,7 +91,7 @@ public function testInvalidEmails($email) '{{ value }}' => $email, )); - $this->assertFalse($this->validator->isValid($email, $constraint)); + $this->validator->isValid($email, $constraint); } public function getInvalidEmails() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php index 5c139764e0fa..90f9f1786829 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new False())); + $this->validator->isValid(null, new False()); } public function testFalseIsValid() @@ -45,7 +45,7 @@ public function testFalseIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(false, new False())); + $this->validator->isValid(false, new False()); } public function testTrueIsInvalid() @@ -58,6 +58,6 @@ public function testTrueIsInvalid() ->method('addViolation') ->with('myMessage', array()); - $this->assertFalse($this->validator->isValid(true, $constraint)); + $this->validator->isValid(true, $constraint); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php index 0d8f76715754..0ef9197a03bd 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php @@ -32,6 +32,6 @@ public function testFileNotFound() '{{ file }}' => 'foobar', )); - $this->assertFalse($this->validator->isValid('foobar', $constraint)); + $this->validator->isValid('foobar', $constraint); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index dd20594f09ce..2201c695a5e7 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -51,7 +51,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new File())); + $this->validator->isValid(null, new File()); } public function testEmptyStringIsValid() @@ -59,7 +59,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new File())); + $this->validator->isValid('', new File()); } /** @@ -75,7 +75,7 @@ public function testValidFile() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($this->path, new File())); + $this->validator->isValid($this->path, new File()); } public function testValidUploadedfile() @@ -84,7 +84,7 @@ public function testValidUploadedfile() ->method('addViolation'); $file = new UploadedFile($this->path, 'originalName'); - $this->assertTrue($this->validator->isValid($file, new File())); + $this->validator->isValid($file, new File()); } public function testTooLargeBytes() @@ -104,7 +104,7 @@ public function testTooLargeBytes() '{{ file }}' => $this->path, )); - $this->assertFalse($this->validator->isValid($this->getFile($this->path), $constraint)); + $this->validator->isValid($this->getFile($this->path), $constraint); } public function testTooLargeKiloBytes() @@ -124,7 +124,7 @@ public function testTooLargeKiloBytes() '{{ file }}' => $this->path, )); - $this->assertFalse($this->validator->isValid($this->getFile($this->path), $constraint)); + $this->validator->isValid($this->getFile($this->path), $constraint); } public function testTooLargeMegaBytes() @@ -144,7 +144,7 @@ public function testTooLargeMegaBytes() '{{ file }}' => $this->path, )); - $this->assertFalse($this->validator->isValid($this->getFile($this->path), $constraint)); + $this->validator->isValid($this->getFile($this->path), $constraint); } /** @@ -184,7 +184,7 @@ public function testValidMimeType() 'mimeTypes' => array('image/png', 'image/jpg'), )); - $this->assertTrue($this->validator->isValid($file, $constraint)); + $this->validator->isValid($file, $constraint); } public function testValidWildcardMimeType() @@ -212,7 +212,7 @@ public function testValidWildcardMimeType() 'mimeTypes' => array('image/*'), )); - $this->assertTrue($this->validator->isValid($file, $constraint)); + $this->validator->isValid($file, $constraint); } public function testInvalidMimeType() @@ -246,7 +246,7 @@ public function testInvalidMimeType() '{{ file }}' => $this->path, )); - $this->assertFalse($this->validator->isValid($file, $constraint)); + $this->validator->isValid($file, $constraint); } public function testInvalidWildcardMimeType() @@ -280,7 +280,7 @@ public function testInvalidWildcardMimeType() '{{ file }}' => $this->path, )); - $this->assertFalse($this->validator->isValid($file, $constraint)); + $this->validator->isValid($file, $constraint); } /** @@ -298,7 +298,7 @@ public function testUploadedFileError($error, $message, array $params = array()) ->method('addViolation') ->with('myMessage', $params); - $this->assertFalse($this->validator->isValid($file, $constraint)); + $this->validator->isValid($file, $constraint); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php index 89c9e8a54d08..8029c2c41caa 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php @@ -34,7 +34,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Image())); + $this->validator->isValid(null, new Image()); } public function testEmptyStringIsValid() @@ -42,7 +42,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new Image())); + $this->validator->isValid('', new Image()); } public function testValidImage() @@ -54,7 +54,7 @@ public function testValidImage() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($this->image, new Image())); + $this->validator->isValid($this->image, new Image()); } public function testValidSize() @@ -73,7 +73,7 @@ public function testValidSize() 'maxHeight' => 2, )); - $this->assertTrue($this->validator->isValid($this->image, $constraint)); + $this->validator->isValid($this->image, $constraint); } public function testWidthTooSmall() @@ -94,7 +94,7 @@ public function testWidthTooSmall() '{{ min_width }}' => '3', )); - $this->assertFalse($this->validator->isValid($this->image, $constraint)); + $this->validator->isValid($this->image, $constraint); } public function testWidthTooBig() @@ -115,7 +115,7 @@ public function testWidthTooBig() '{{ max_width }}' => '1', )); - $this->assertFalse($this->validator->isValid($this->image, $constraint)); + $this->validator->isValid($this->image, $constraint); } public function testHeightTooSmall() @@ -136,7 +136,7 @@ public function testHeightTooSmall() '{{ min_height }}' => '3', )); - $this->assertFalse($this->validator->isValid($this->image, $constraint)); + $this->validator->isValid($this->image, $constraint); } public function testHeightTooBig() @@ -157,7 +157,7 @@ public function testHeightTooBig() '{{ max_height }}' => '1', )); - $this->assertFalse($this->validator->isValid($this->image, $constraint)); + $this->validator->isValid($this->image, $constraint); } /** diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php index 6c1ddf74ed3f..0ee24a8952d9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Ip())); + $this->validator->isValid(null, new Ip()); } public function testEmptyStringIsValid() @@ -45,7 +45,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new Ip())); + $this->validator->isValid('', new Ip()); } /** @@ -74,9 +74,9 @@ public function testValidIpsV4($ip) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($ip, new Ip(array( + $this->validator->isValid($ip, new Ip(array( 'version' => Ip::V4, - )))); + ))); } public function getValidIpsV4() @@ -101,9 +101,9 @@ public function testValidIpsV6($ip) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($ip, new Ip(array( + $this->validator->isValid($ip, new Ip(array( 'version' => Ip::V6, - )))); + ))); } public function getValidIpsV6() @@ -139,9 +139,9 @@ public function testValidIpsAll($ip) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($ip, new Ip(array( + $this->validator->isValid($ip, new Ip(array( 'version' => Ip::ALL, - )))); + ))); } public function getValidIpsAll() @@ -165,7 +165,7 @@ public function testInvalidIpsV4($ip) '{{ value }}' => $ip, )); - $this->assertFalse($this->validator->isValid($ip, $constraint)); + $this->validator->isValid($ip, $constraint); } public function getInvalidIpsV4() @@ -199,7 +199,7 @@ public function testInvalidPrivateIpsV4($ip) '{{ value }}' => $ip, )); - $this->assertFalse($this->validator->isValid($ip, $constraint)); + $this->validator->isValid($ip, $constraint); } public function getInvalidPrivateIpsV4() @@ -227,7 +227,7 @@ public function testInvalidReservedIpsV4($ip) '{{ value }}' => $ip, )); - $this->assertFalse($this->validator->isValid($ip, $constraint)); + $this->validator->isValid($ip, $constraint); } public function getInvalidReservedIpsV4() @@ -255,7 +255,7 @@ public function testInvalidPublicIpsV4($ip) '{{ value }}' => $ip, )); - $this->assertFalse($this->validator->isValid($ip, $constraint)); + $this->validator->isValid($ip, $constraint); } public function getInvalidPublicIpsV4() @@ -279,7 +279,7 @@ public function testInvalidIpsV6($ip) '{{ value }}' => $ip, )); - $this->assertFalse($this->validator->isValid($ip, $constraint)); + $this->validator->isValid($ip, $constraint); } public function getInvalidIpsV6() @@ -317,7 +317,7 @@ public function testInvalidPrivateIpsV6($ip) '{{ value }}' => $ip, )); - $this->assertFalse($this->validator->isValid($ip, $constraint)); + $this->validator->isValid($ip, $constraint); } public function getInvalidPrivateIpsV6() @@ -345,7 +345,7 @@ public function testInvalidReservedIpsV6($ip) '{{ value }}' => $ip, )); - $this->assertFalse($this->validator->isValid($ip, $constraint)); + $this->validator->isValid($ip, $constraint); } public function getInvalidReservedIpsV6() @@ -372,7 +372,7 @@ public function testInvalidPublicIpsV6($ip) '{{ value }}' => $ip, )); - $this->assertFalse($this->validator->isValid($ip, $constraint)); + $this->validator->isValid($ip, $constraint); } public function getInvalidPublicIpsV6() @@ -396,7 +396,7 @@ public function testInvalidIpsAll($ip) '{{ value }}' => $ip, )); - $this->assertFalse($this->validator->isValid($ip, $constraint)); + $this->validator->isValid($ip, $constraint); } public function getInvalidIpsAll() @@ -420,7 +420,7 @@ public function testInvalidPrivateIpsAll($ip) '{{ value }}' => $ip, )); - $this->assertFalse($this->validator->isValid($ip, $constraint)); + $this->validator->isValid($ip, $constraint); } public function getInvalidPrivateIpsAll() @@ -444,7 +444,7 @@ public function testInvalidReservedIpsAll($ip) '{{ value }}' => $ip, )); - $this->assertFalse($this->validator->isValid($ip, $constraint)); + $this->validator->isValid($ip, $constraint); } public function getInvalidReservedIpsAll() @@ -468,7 +468,7 @@ public function testInvalidPublicIpsAll($ip) '{{ value }}' => $ip, )); - $this->assertFalse($this->validator->isValid($ip, $constraint)); + $this->validator->isValid($ip, $constraint); } public function getInvalidPublicIpsAll() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php index a5c1a9b2a84b..1c7438c51f09 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php @@ -39,7 +39,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Language())); + $this->validator->isValid(null, new Language()); } public function testEmptyStringIsValid() @@ -47,7 +47,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new Language())); + $this->validator->isValid('', new Language()); } /** @@ -70,7 +70,7 @@ public function testValidLanguages($language) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($language, new Language())); + $this->validator->isValid($language, new Language()); } public function getValidLanguages() @@ -101,7 +101,7 @@ public function testInvalidLanguages($language) '{{ value }}' => $language, )); - $this->assertFalse($this->validator->isValid($language, $constraint)); + $this->validator->isValid($language, $constraint); } public function getInvalidLanguages() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php index 61ea2c7c0d31..5f150df193b8 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php @@ -39,7 +39,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Locale())); + $this->validator->isValid(null, new Locale()); } public function testEmptyStringIsValid() @@ -47,7 +47,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new Locale())); + $this->validator->isValid('', new Locale()); } /** @@ -70,7 +70,7 @@ public function testValidLocales($locale) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($locale, new Locale())); + $this->validator->isValid($locale, new Locale()); } public function getValidLocales() @@ -102,7 +102,7 @@ public function testInvalidLocales($locale) '{{ value }}' => $locale, )); - $this->assertFalse($this->validator->isValid($locale, $constraint)); + $this->validator->isValid($locale, $constraint); } public function getInvalidLocales() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/MaxLengthValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/MaxLengthValidatorTest.php index 5bf5f390a8e9..5e61aded08e1 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/MaxLengthValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/MaxLengthValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new MaxLength(array('limit' => 5)))); + $this->validator->isValid(null, new MaxLength(array('limit' => 5))); } public function testEmptyStringIsValid() @@ -45,7 +45,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new MaxLength(array('limit' => 5)))); + $this->validator->isValid('', new MaxLength(array('limit' => 5))); } /** @@ -69,7 +69,7 @@ public function testValidValues($value, $mbOnly = false) ->method('addViolation'); $constraint = new MaxLength(array('limit' => 5)); - $this->assertTrue($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getValidValues() @@ -103,7 +103,7 @@ public function testInvalidValues($value, $mbOnly = false) '{{ limit }}' => 5, ), null, 5); - $this->assertFalse($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getInvalidValues() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/MaxValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/MaxValidatorTest.php index 6b591917f7a9..bbb5a4d5740d 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/MaxValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/MaxValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Max(array('limit' => 10)))); + $this->validator->isValid(null, new Max(array('limit' => 10))); } /** @@ -49,7 +49,7 @@ public function testValidValues($value) ->method('addViolation'); $constraint = new Max(array('limit' => 10)); - $this->assertTrue($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getValidValues() @@ -80,7 +80,7 @@ public function testInvalidValues($value) '{{ limit }}' => 10, )); - $this->assertFalse($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getInvalidValues() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/MinLengthValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/MinLengthValidatorTest.php index a6ff71b7f3a5..4488b6ddef7e 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/MinLengthValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/MinLengthValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new MinLength(array('limit' => 6)))); + $this->validator->isValid(null, new MinLength(array('limit' => 6))); } public function testEmptyStringIsValid() @@ -45,7 +45,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new MinLength(array('limit' => 6)))); + $this->validator->isValid('', new MinLength(array('limit' => 6))); } /** @@ -69,7 +69,7 @@ public function testValidValues($value, $mbOnly = false) ->method('addViolation'); $constraint = new MinLength(array('limit' => 6)); - $this->assertTrue($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getValidValues() @@ -103,7 +103,7 @@ public function testInvalidValues($value, $mbOnly = false) '{{ limit }}' => 5, ), null, 5); - $this->assertFalse($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getInvalidValues() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/MinValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/MinValidatorTest.php index 3f9340db0fa2..4bcb831d9ef5 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/MinValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/MinValidatorTest.php @@ -31,7 +31,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Min(array('limit' => 10)))); + $this->validator->isValid(null, new Min(array('limit' => 10))); } /** @@ -43,7 +43,7 @@ public function testValidValues($value) ->method('addViolation'); $constraint = new Min(array('limit' => 10)); - $this->assertTrue($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getValidValues() @@ -74,7 +74,7 @@ public function testInvalidValues($value) '{{ limit }}' => 10, )); - $this->assertFalse($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getInvalidValues() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php index f282fd7f64c4..ce9febbc40d7 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php @@ -40,7 +40,7 @@ public function testValidValues($date) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($date, new NotBlank())); + $this->validator->isValid($date, new NotBlank()); } public function getValidValues() @@ -64,7 +64,7 @@ public function testNullIsInvalid() ->method('addViolation') ->with('myMessage'); - $this->assertFalse($this->validator->isValid(null, $constraint)); + $this->validator->isValid(null, $constraint); } public function testBlankIsInvalid() @@ -77,7 +77,7 @@ public function testBlankIsInvalid() ->method('addViolation') ->with('myMessage'); - $this->assertFalse($this->validator->isValid('', $constraint)); + $this->validator->isValid('', $constraint); } public function testFalseIsInvalid() @@ -90,7 +90,7 @@ public function testFalseIsInvalid() ->method('addViolation') ->with('myMessage'); - $this->assertFalse($this->validator->isValid(false, $constraint)); + $this->validator->isValid(false, $constraint); } public function testEmptyArrayIsInvalid() @@ -103,7 +103,7 @@ public function testEmptyArrayIsInvalid() ->method('addViolation') ->with('myMessage'); - $this->assertFalse($this->validator->isValid(array(), $constraint)); + $this->validator->isValid(array(), $constraint); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php index 6ca163bfd148..03c79b63ec81 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php @@ -40,7 +40,7 @@ public function testValidValues($value) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($value, new NotNull())); + $this->validator->isValid($value, new NotNull()); } public function getValidValues() @@ -64,6 +64,6 @@ public function testNullIsInvalid() ->with('myMessage', array( )); - $this->assertFalse($this->validator->isValid(null, $constraint)); + $this->validator->isValid(null, $constraint); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php index df481bc0371b..f098f3d62a86 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Null())); + $this->validator->isValid(null, new Null()); } /** @@ -55,7 +55,7 @@ public function testInvalidValues($value) '{{ value }}' => $value, )); - $this->assertFalse($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getInvalidValues() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php index 03e410919a31..fcc27dc62ea0 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Regex(array('pattern' => '/^[0-9]+$/')))); + $this->validator->isValid(null, new Regex(array('pattern' => '/^[0-9]+$/'))); } public function testEmptyStringIsValid() @@ -45,7 +45,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new Regex(array('pattern' => '/^[0-9]+$/')))); + $this->validator->isValid('', new Regex(array('pattern' => '/^[0-9]+$/'))); } /** @@ -65,7 +65,7 @@ public function testValidValues($value) ->method('addViolation'); $constraint = new Regex(array('pattern' => '/^[0-9]+$/')); - $this->assertTrue($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getValidValues() @@ -94,7 +94,7 @@ public function testInvalidValues($value) '{{ value }}' => $value, )); - $this->assertFalse($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getInvalidValues() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/SizeLengthValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/SizeLengthValidatorTest.php index dd334270a773..b8c2d20440a2 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/SizeLengthValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/SizeLengthValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new SizeLength(array('min' => 6, 'max' => 10)))); + $this->validator->isValid(null, new SizeLength(array('min' => 6, 'max' => 10))); } public function testEmptyStringIsValid() @@ -45,7 +45,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new SizeLength(array('min' => 6, 'max' => 10)))); + $this->validator->isValid('', new SizeLength(array('min' => 6, 'max' => 10))); } /** @@ -69,7 +69,7 @@ public function testValidValues($value, $mbOnly = false) ->method('addViolation'); $constraint = new SizeLength(array('min' => 6, 'max' => 10)); - $this->assertTrue($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getValidValues() @@ -99,7 +99,7 @@ public function testInvalidValues($value, $mbOnly = false) ->method('addViolation'); $constraint = new SizeLength(array('min' => 6, 'max' => 10)); - $this->assertFalse($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getInvalidValues() @@ -131,7 +131,7 @@ public function testMinMessageIsSet() '{{ limit }}' => 5, ), null, 5); - $this->assertFalse($this->validator->isValid('1234', $constraint)); + $this->validator->isValid('1234', $constraint); } public function testMaxMessageIsSet() @@ -149,7 +149,7 @@ public function testMaxMessageIsSet() '{{ limit }}' => 10, ), null, 10); - $this->assertFalse($this->validator->isValid('12345678901', $constraint)); + $this->validator->isValid('12345678901', $constraint); } public function testExactMessageIsSet() @@ -167,6 +167,6 @@ public function testExactMessageIsSet() '{{ limit }}' => 5, ), null, 5); - $this->assertFalse($this->validator->isValid('1234', $constraint)); + $this->validator->isValid('1234', $constraint); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/SizeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/SizeValidatorTest.php index 2764d325ce5e..0b6099d47c20 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/SizeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/SizeValidatorTest.php @@ -31,7 +31,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Size(array('min' => 10, 'max' => 20)))); + $this->validator->isValid(null, new Size(array('min' => 10, 'max' => 20))); } /** @@ -43,7 +43,7 @@ public function testValidValues($value) ->method('addViolation'); $constraint = new Size(array('min' => 10, 'max' => 20)); - $this->assertTrue($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getValidValues() @@ -69,7 +69,7 @@ public function testInvalidValues($value) ->method('addViolation'); $constraint = new Size(array('min' => 10, 'max' => 20)); - $this->assertFalse($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getInvalidValues() @@ -98,7 +98,7 @@ public function testMinMessageIsSet() '{{ limit }}' => 10, )); - $this->assertFalse($this->validator->isValid(9, $constraint)); + $this->validator->isValid(9, $constraint); } public function testMaxMessageIsSet() @@ -116,6 +116,6 @@ public function testMaxMessageIsSet() '{{ limit }}' => 20, )); - $this->assertFalse($this->validator->isValid(21, $constraint)); + $this->validator->isValid(21, $constraint); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php index cd57f350d5e9..878368bef1c2 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Time())); + $this->validator->isValid(null, new Time()); } public function testEmptyStringIsValid() @@ -45,7 +45,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new Time())); + $this->validator->isValid('', new Time()); } public function testDateTimeClassIsValid() @@ -53,7 +53,7 @@ public function testDateTimeClassIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(new \DateTime(), new Time())); + $this->validator->isValid(new \DateTime(), new Time()); } /** @@ -72,7 +72,7 @@ public function testValidTimes($time) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($time, new Time())); + $this->validator->isValid($time, new Time()); } public function getValidTimes() @@ -99,7 +99,7 @@ public function testInvalidTimes($time) '{{ value }}' => $time, )); - $this->assertFalse($this->validator->isValid($time, $constraint)); + $this->validator->isValid($time, $constraint); } public function getInvalidTimes() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php index cc5be6495200..8c1d7dddcf0e 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new True())); + $this->validator->isValid(null, new True()); } public function testTrueIsValid() @@ -45,7 +45,7 @@ public function testTrueIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(true, new True())); + $this->validator->isValid(true, new True()); } public function testFalseIsInvalid() @@ -59,6 +59,6 @@ public function testFalseIsInvalid() ->with('myMessage', array( )); - $this->assertFalse($this->validator->isValid(false, $constraint)); + $this->validator->isValid(false, $constraint); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php index 8d6d3a257cd9..3dd4ed9e1162 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php @@ -39,7 +39,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Type(array('type' => 'integer')))); + $this->validator->isValid(null, new Type(array('type' => 'integer'))); } public function testEmptyIsValidIfString() @@ -47,12 +47,12 @@ public function testEmptyIsValidIfString() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new Type(array('type' => 'string')))); + $this->validator->isValid('', new Type(array('type' => 'string'))); } public function testEmptyIsInvalidIfNoString() { - $this->assertFalse($this->validator->isValid('', new Type(array('type' => 'integer')))); + $this->validator->isValid('', new Type(array('type' => 'integer'))); } /** @@ -65,7 +65,7 @@ public function testValidValues($value, $type) $constraint = new Type(array('type' => $type)); - $this->assertTrue($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getValidValues() @@ -122,7 +122,7 @@ public function testInvalidValues($value, $type, $valueAsString) '{{ type }}' => $type, )); - $this->assertFalse($this->validator->isValid($value, $constraint)); + $this->validator->isValid($value, $constraint); } public function getInvalidValues() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index dc599cc55c35..e9b05192cc22 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -37,7 +37,7 @@ public function testNullIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid(null, new Url())); + $this->validator->isValid(null, new Url()); } public function testEmptyStringIsValid() @@ -45,7 +45,7 @@ public function testEmptyStringIsValid() $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid('', new Url())); + $this->validator->isValid('', new Url()); } /** @@ -64,7 +64,7 @@ public function testValidUrls($url) $this->context->expects($this->never()) ->method('addViolation'); - $this->assertTrue($this->validator->isValid($url, new Url())); + $this->validator->isValid($url, new Url()); } public function getValidUrls() @@ -119,7 +119,7 @@ public function testInvalidUrls($url) '{{ value }}' => $url, )); - $this->assertFalse($this->validator->isValid($url, $constraint)); + $this->validator->isValid($url, $constraint); } public function getInvalidUrls() @@ -154,7 +154,7 @@ public function testCustomProtocolIsValid($url) 'protocols' => array('ftp', 'file', 'git') )); - $this->assertTrue($this->validator->isValid($url, $constraint)); + $this->validator->isValid($url, $constraint); } public function getValidCustomUrls() diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintAValidator.php b/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintAValidator.php index 97b65605a5e9..890f447ab6ed 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintAValidator.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintAValidator.php @@ -31,9 +31,9 @@ public function isValid($value, Constraint $constraint) if ('VALID' != $value) { $this->context->addViolation('message', array('param' => 'value')); - return false; + return; } - return true; + return; } } diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/FailingConstraintValidator.php b/src/Symfony/Component/Validator/Tests/Fixtures/FailingConstraintValidator.php index 26c2dccfa48a..73d7a61bb395 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/FailingConstraintValidator.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/FailingConstraintValidator.php @@ -20,6 +20,6 @@ public function isValid($value, Constraint $constraint) { $this->context->addViolation($constraint->message, array()); - return false; + return; } }