[Validator] Removed return value from ConstraintValidatorInterface::isValid()
This commit is contained in:
parent
e7470ffebb
commit
46f0393f70
@ -40,8 +40,6 @@ class UniqueEntityValidator extends ConstraintValidator
|
||||
/**
|
||||
* @param object $entity
|
||||
* @param Constraint $constraint
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid($entity, Constraint $constraint)
|
||||
{
|
||||
@ -74,7 +72,7 @@ class UniqueEntityValidator extends ConstraintValidator
|
||||
$criteria[$fieldName] = $class->reflFields[$fieldName]->getValue($entity);
|
||||
|
||||
if (null === $criteria[$fieldName]) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($class->hasAssociation($fieldName)) {
|
||||
@ -113,11 +111,9 @@ class UniqueEntityValidator extends ConstraintValidator
|
||||
* 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!
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,6 @@ class UserPasswordValidator extends ConstraintValidator
|
||||
|
||||
if (!$encoder->isPasswordValid($user->getPassword(), $password, $user->getSalt())) {
|
||||
$this->context->addViolation($constraint->message);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,6 @@ interface ConstraintValidatorInterface
|
||||
* @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);
|
||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class AllValidator extends ConstraintValidator
|
||||
$walker->walkConstraint($constr, $element, $group, $propertyPath.'['.$key.']');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||
/**
|
||||
* Validator for Callback constraint
|
||||
*
|
||||
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class CallbackValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
$methods = $constraint->methods;
|
||||
$success = true;
|
||||
|
||||
foreach ($methods as $method) {
|
||||
if (is_array($method) || $method instanceof \Closure) {
|
||||
@ -56,16 +53,14 @@ class CallbackValidator extends ConstraintValidator
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Florian Eckerstorfer <florian@eckerstorfer.org>
|
||||
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class ChoiceValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($constraint->multiple && !is_array($value)) {
|
||||
@ -67,8 +65,6 @@ class ChoiceValidator extends ConstraintValidator
|
||||
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 @@ class ChoiceValidator extends ConstraintValidator
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ use Symfony\Component\Validator\Constraints\Collection\Optional;
|
||||
use Symfony\Component\Validator\Constraints\Collection\Required;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class CollectionValidator extends ConstraintValidator
|
||||
$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 @@ class CollectionValidator extends ConstraintValidator
|
||||
$this->context->addViolationAtSubPath('['.$field.']', $constraint->missingFieldsMessage, array(
|
||||
'{{ field }}' => $field
|
||||
), null);
|
||||
$valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,11 +78,8 @@ class CollectionValidator extends ConstraintValidator
|
||||
$this->context->addViolationAtSubPath('['.$field.']', $constraint->extraFieldsMessage, array(
|
||||
'{{ field }}' => $field
|
||||
), $fieldValue);
|
||||
$valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $valid;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
/**
|
||||
* Validates whether a value is a valid country code
|
||||
*
|
||||
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class CountryValidator extends ConstraintValidator
|
||||
|
||||
if (!in_array($value, \Symfony\Component\Locale\Locale::getCountries())) {
|
||||
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,8 @@
|
||||
namespace Symfony\Component\Validator\Constraints;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class DateTimeValidator extends DateValidator
|
||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class DateValidator extends ConstraintValidator
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class EmailValidator extends ConstraintValidator
|
||||
|
||||
if (!$valid) {
|
||||
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,6 +15,8 @@ use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ use Symfony\Component\HttpFoundation\File\File as FileObject;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class FileValidator extends ConstraintValidator
|
||||
$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 @@ class FileValidator extends ConstraintValidator
|
||||
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 @@ class FileValidator extends ConstraintValidator
|
||||
'{{ file }}' => $path,
|
||||
));
|
||||
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,11 +153,7 @@ class FileValidator extends ConstraintValidator
|
||||
'{{ types }}' => '"'.implode('", "', $mimeTypes) .'"',
|
||||
'{{ file }}' => $path,
|
||||
));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
|
||||
if (null === $value || '' === $value) {
|
||||
return true;
|
||||
parent::isValid($value, $constraint);
|
||||
|
||||
$isValid = count($this->context->getViolations()) === $violations;
|
||||
|
||||
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 @@ class ImageValidator extends FileValidator
|
||||
'{{ min_width }}' => $constraint->minWidth
|
||||
));
|
||||
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,7 +75,7 @@ class ImageValidator extends FileValidator
|
||||
'{{ max_width }}' => $constraint->maxWidth
|
||||
));
|
||||
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +90,7 @@ class ImageValidator extends FileValidator
|
||||
'{{ min_height }}' => $constraint->minHeight
|
||||
));
|
||||
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,11 +104,7 @@ class ImageValidator extends FileValidator
|
||||
'{{ height }}' => $height,
|
||||
'{{ max_height }}' => $constraint->maxHeight
|
||||
));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
/**
|
||||
* Validates whether a value is a valid IP address
|
||||
*
|
||||
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
* @author Joseph Bielawski <stloyd@gmail.com>
|
||||
*
|
||||
* @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 @@ class IpValidator extends ConstraintValidator
|
||||
|
||||
if (!filter_var($value, FILTER_VALIDATE_IP, $flag)) {
|
||||
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
/**
|
||||
* Validates whether a value is a valid language code
|
||||
*
|
||||
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class LanguageValidator extends ConstraintValidator
|
||||
|
||||
if (!in_array($value, \Symfony\Component\Locale\Locale::getLanguages())) {
|
||||
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
/**
|
||||
* Validates whether a value is a valid locale code
|
||||
*
|
||||
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class LocaleValidator extends ConstraintValidator
|
||||
|
||||
if (!in_array($value, \Symfony\Component\Locale\Locale::getLocales())) {
|
||||
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class MaxLengthValidator extends ConstraintValidator
|
||||
'{{ value }}' => $value,
|
||||
'{{ limit }}' => $constraint->limit,
|
||||
), null, (int) $constraint->limit);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class MaxValidator extends ConstraintValidator
|
||||
'{{ limit }}' => $constraint->limit,
|
||||
));
|
||||
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($value > $constraint->limit) {
|
||||
@ -49,10 +49,6 @@ class MaxValidator extends ConstraintValidator
|
||||
'{{ value }}' => $value,
|
||||
'{{ limit }}' => $constraint->limit,
|
||||
));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class MinLengthValidator extends ConstraintValidator
|
||||
'{{ value }}' => $value,
|
||||
'{{ limit }}' => $constraint->limit,
|
||||
), null, (int) $constraint->limit);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class MinValidator extends ConstraintValidator
|
||||
'{{ limit }}' => $constraint->limit,
|
||||
));
|
||||
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($value < $constraint->limit) {
|
||||
@ -49,10 +49,6 @@ class MinValidator extends ConstraintValidator
|
||||
'{{ value }}' => $value,
|
||||
'{{ limit }}' => $constraint->limit,
|
||||
));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
/**
|
||||
* Validates whether a value match or not given regexp pattern
|
||||
*
|
||||
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
* @author Joseph Bielawski <stloyd@gmail.com>
|
||||
*
|
||||
* @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 @@ class RegexValidator extends ConstraintValidator
|
||||
|
||||
if ($constraint->match xor preg_match($constraint->pattern, $value)) {
|
||||
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ class SizeLengthValidator extends ConstraintValidator
|
||||
'{{ limit }}' => $constraint->max,
|
||||
), null, (int) $constraint->max);
|
||||
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($length > $constraint->max) {
|
||||
@ -65,7 +63,7 @@ class SizeLengthValidator extends ConstraintValidator
|
||||
'{{ limit }}' => $constraint->max,
|
||||
), null, (int) $constraint->max);
|
||||
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($length < $constraint->min) {
|
||||
@ -73,10 +71,6 @@ class SizeLengthValidator extends ConstraintValidator
|
||||
'{{ value }}' => $value,
|
||||
'{{ limit }}' => $constraint->min,
|
||||
), null, (int) $constraint->min);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class SizeValidator extends ConstraintValidator
|
||||
'{{ value }}' => $value,
|
||||
));
|
||||
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($value > $constraint->max) {
|
||||
@ -49,7 +51,7 @@ class SizeValidator extends ConstraintValidator
|
||||
'{{ limit }}' => $constraint->max,
|
||||
));
|
||||
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($value < $constraint->min) {
|
||||
@ -57,10 +59,6 @@ class SizeValidator extends ConstraintValidator
|
||||
'{{ value }}' => $value,
|
||||
'{{ limit }}' => $constraint->min,
|
||||
));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class TimeValidator extends ConstraintValidator
|
||||
|
||||
if (!preg_match(static::PATTERN, $value)) {
|
||||
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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)
|
||||
|
@ -15,6 +15,8 @@ use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class TypeValidator extends ConstraintValidator
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @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 @@ class UrlValidator extends ConstraintValidator
|
||||
|
||||
if (!preg_match($pattern, $value)) {
|
||||
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,10 @@ class AllValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
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 @@ class AllValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class AllValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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()
|
||||
|
@ -37,7 +37,7 @@ class BlankValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class BlankValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->context->expects($this->never())
|
||||
->method('addViolation');
|
||||
|
||||
$this->assertTrue($this->validator->isValid('', new Blank()));
|
||||
$this->validator->isValid('', new Blank());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,7 +63,7 @@ class BlankValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $value,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($value, $constraint));
|
||||
$this->validator->isValid($value, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidValues()
|
||||
|
@ -65,7 +65,7 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => 'foobar',
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($object, $constraint));
|
||||
$this->validator->isValid($object, $constraint);
|
||||
}
|
||||
|
||||
public function testCallbackSingleStaticMethod()
|
||||
@ -92,9 +92,9 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ 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 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
));
|
||||
|
||||
|
||||
$this->assertFalse($this->validator->isValid($object, new Callback(array(
|
||||
$this->validator->isValid($object, new Callback(array(
|
||||
'validateOne', 'validateTwo'
|
||||
))));
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => 'baz',
|
||||
), null, null);
|
||||
|
||||
$this->assertFalse($this->validator->isValid('baz', $constraint));
|
||||
$this->validator->isValid('baz', $constraint);
|
||||
}
|
||||
|
||||
public function testInvalidChoiceMultiple()
|
||||
@ -180,7 +180,7 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ 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 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ 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 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ 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 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => '2',
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid('2', $constraint));
|
||||
$this->validator->isValid('2', $constraint);
|
||||
}
|
||||
|
||||
public function testNonStrictWithMultipleChoices()
|
||||
@ -274,7 +274,7 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => '3',
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid(array(2, '3'), $constraint));
|
||||
$this->validator->isValid(array(2, '3'), $constraint);
|
||||
}
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ 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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ field }}' => 'foo',
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($data, $constraint));
|
||||
$this->validator->isValid($data, $constraint);
|
||||
}
|
||||
|
||||
public function testMissingFieldsAllowed()
|
||||
@ -242,7 +242,7 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ 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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$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 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$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()
|
||||
|
@ -39,7 +39,7 @@ class CountryValidatorTest extends LocalizedTestCase
|
||||
$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 @@ class CountryValidatorTest extends LocalizedTestCase
|
||||
$this->context->expects($this->never())
|
||||
->method('addViolation');
|
||||
|
||||
$this->assertTrue($this->validator->isValid('', new Country()));
|
||||
$this->validator->isValid('', new Country());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,7 +70,7 @@ class CountryValidatorTest extends LocalizedTestCase
|
||||
$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 @@ class CountryValidatorTest extends LocalizedTestCase
|
||||
'{{ value }}' => $country,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($country, $constraint));
|
||||
$this->validator->isValid($country, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidCountries()
|
||||
|
@ -37,7 +37,7 @@ class DateTimeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class DateTimeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class DateTimeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class DateTimeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class DateTimeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $dateTime,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($dateTime, $constraint));
|
||||
$this->validator->isValid($dateTime, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidDateTimes()
|
||||
|
@ -37,7 +37,7 @@ class DateValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class DateValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class DateValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class DateValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class DateValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $date,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($date, $constraint));
|
||||
$this->validator->isValid($date, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidDates()
|
||||
|
@ -37,7 +37,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->context->expects($this->never())
|
||||
->method('addViolation');
|
||||
|
||||
$this->assertTrue($this->validator->isValid('', new Email()));
|
||||
$this->validator->isValid('', new Email());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,7 +64,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $email,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($email, $constraint));
|
||||
$this->validator->isValid($email, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidEmails()
|
||||
|
@ -37,7 +37,7 @@ class FalseValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class FalseValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class FalseValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->method('addViolation')
|
||||
->with('myMessage', array());
|
||||
|
||||
$this->assertFalse($this->validator->isValid(true, $constraint));
|
||||
$this->validator->isValid(true, $constraint);
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,6 @@ class FileValidatorPathTest extends FileValidatorTest
|
||||
'{{ file }}' => 'foobar',
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid('foobar', $constraint));
|
||||
$this->validator->isValid('foobar', $constraint);
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->context->expects($this->never())
|
||||
->method('addViolation');
|
||||
|
||||
$this->assertTrue($this->validator->isValid('', new File()));
|
||||
$this->validator->isValid('', new File());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,7 +75,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->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 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ 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 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ 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 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ 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 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'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 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'mimeTypes' => array('image/*'),
|
||||
));
|
||||
|
||||
$this->assertTrue($this->validator->isValid($file, $constraint));
|
||||
$this->validator->isValid($file, $constraint);
|
||||
}
|
||||
|
||||
public function testInvalidMimeType()
|
||||
@ -246,7 +246,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ file }}' => $this->path,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($file, $constraint));
|
||||
$this->validator->isValid($file, $constraint);
|
||||
}
|
||||
|
||||
public function testInvalidWildcardMimeType()
|
||||
@ -280,7 +280,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ file }}' => $this->path,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($file, $constraint));
|
||||
$this->validator->isValid($file, $constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,7 +298,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->method('addViolation')
|
||||
->with('myMessage', $params);
|
||||
|
||||
$this->assertFalse($this->validator->isValid($file, $constraint));
|
||||
$this->validator->isValid($file, $constraint);
|
||||
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'maxHeight' => 2,
|
||||
));
|
||||
|
||||
$this->assertTrue($this->validator->isValid($this->image, $constraint));
|
||||
$this->validator->isValid($this->image, $constraint);
|
||||
}
|
||||
|
||||
public function testWidthTooSmall()
|
||||
@ -94,7 +94,7 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ min_width }}' => '3',
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($this->image, $constraint));
|
||||
$this->validator->isValid($this->image, $constraint);
|
||||
}
|
||||
|
||||
public function testWidthTooBig()
|
||||
@ -115,7 +115,7 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ max_width }}' => '1',
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($this->image, $constraint));
|
||||
$this->validator->isValid($this->image, $constraint);
|
||||
}
|
||||
|
||||
public function testHeightTooSmall()
|
||||
@ -136,7 +136,7 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ min_height }}' => '3',
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($this->image, $constraint));
|
||||
$this->validator->isValid($this->image, $constraint);
|
||||
}
|
||||
|
||||
public function testHeightTooBig()
|
||||
@ -157,7 +157,7 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ max_height }}' => '1',
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($this->image, $constraint));
|
||||
$this->validator->isValid($this->image, $constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->context->expects($this->never())
|
||||
->method('addViolation');
|
||||
|
||||
$this->assertTrue($this->validator->isValid('', new Ip()));
|
||||
$this->validator->isValid('', new Ip());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,9 +74,9 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $ip,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($ip, $constraint));
|
||||
$this->validator->isValid($ip, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidIpsV4()
|
||||
@ -199,7 +199,7 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $ip,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($ip, $constraint));
|
||||
$this->validator->isValid($ip, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidPrivateIpsV4()
|
||||
@ -227,7 +227,7 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $ip,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($ip, $constraint));
|
||||
$this->validator->isValid($ip, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidReservedIpsV4()
|
||||
@ -255,7 +255,7 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $ip,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($ip, $constraint));
|
||||
$this->validator->isValid($ip, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidPublicIpsV4()
|
||||
@ -279,7 +279,7 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $ip,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($ip, $constraint));
|
||||
$this->validator->isValid($ip, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidIpsV6()
|
||||
@ -317,7 +317,7 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $ip,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($ip, $constraint));
|
||||
$this->validator->isValid($ip, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidPrivateIpsV6()
|
||||
@ -345,7 +345,7 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $ip,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($ip, $constraint));
|
||||
$this->validator->isValid($ip, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidReservedIpsV6()
|
||||
@ -372,7 +372,7 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $ip,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($ip, $constraint));
|
||||
$this->validator->isValid($ip, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidPublicIpsV6()
|
||||
@ -396,7 +396,7 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $ip,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($ip, $constraint));
|
||||
$this->validator->isValid($ip, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidIpsAll()
|
||||
@ -420,7 +420,7 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $ip,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($ip, $constraint));
|
||||
$this->validator->isValid($ip, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidPrivateIpsAll()
|
||||
@ -444,7 +444,7 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $ip,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($ip, $constraint));
|
||||
$this->validator->isValid($ip, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidReservedIpsAll()
|
||||
@ -468,7 +468,7 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $ip,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($ip, $constraint));
|
||||
$this->validator->isValid($ip, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidPublicIpsAll()
|
||||
|
@ -39,7 +39,7 @@ class LanguageValidatorTest extends LocalizedTestCase
|
||||
$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 @@ class LanguageValidatorTest extends LocalizedTestCase
|
||||
$this->context->expects($this->never())
|
||||
->method('addViolation');
|
||||
|
||||
$this->assertTrue($this->validator->isValid('', new Language()));
|
||||
$this->validator->isValid('', new Language());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,7 +70,7 @@ class LanguageValidatorTest extends LocalizedTestCase
|
||||
$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 @@ class LanguageValidatorTest extends LocalizedTestCase
|
||||
'{{ value }}' => $language,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($language, $constraint));
|
||||
$this->validator->isValid($language, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidLanguages()
|
||||
|
@ -39,7 +39,7 @@ class LocaleValidatorTest extends LocalizedTestCase
|
||||
$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 @@ class LocaleValidatorTest extends LocalizedTestCase
|
||||
$this->context->expects($this->never())
|
||||
->method('addViolation');
|
||||
|
||||
$this->assertTrue($this->validator->isValid('', new Locale()));
|
||||
$this->validator->isValid('', new Locale());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,7 +70,7 @@ class LocaleValidatorTest extends LocalizedTestCase
|
||||
$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 @@ class LocaleValidatorTest extends LocalizedTestCase
|
||||
'{{ value }}' => $locale,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($locale, $constraint));
|
||||
$this->validator->isValid($locale, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidLocales()
|
||||
|
@ -37,7 +37,7 @@ class MaxLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class MaxLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class MaxLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->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 @@ class MaxLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ limit }}' => 5,
|
||||
), null, 5);
|
||||
|
||||
$this->assertFalse($this->validator->isValid($value, $constraint));
|
||||
$this->validator->isValid($value, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidValues()
|
||||
|
@ -37,7 +37,7 @@ class MaxValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class MaxValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->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 @@ class MaxValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ limit }}' => 10,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($value, $constraint));
|
||||
$this->validator->isValid($value, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidValues()
|
||||
|
@ -37,7 +37,7 @@ class MinLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class MinLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class MinLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->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 @@ class MinLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ limit }}' => 5,
|
||||
), null, 5);
|
||||
|
||||
$this->assertFalse($this->validator->isValid($value, $constraint));
|
||||
$this->validator->isValid($value, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidValues()
|
||||
|
@ -31,7 +31,7 @@ class MinValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class MinValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->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 @@ class MinValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ limit }}' => 10,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($value, $constraint));
|
||||
$this->validator->isValid($value, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidValues()
|
||||
|
@ -40,7 +40,7 @@ class NotBlankValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class NotBlankValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->method('addViolation')
|
||||
->with('myMessage');
|
||||
|
||||
$this->assertFalse($this->validator->isValid(null, $constraint));
|
||||
$this->validator->isValid(null, $constraint);
|
||||
}
|
||||
|
||||
public function testBlankIsInvalid()
|
||||
@ -77,7 +77,7 @@ class NotBlankValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->method('addViolation')
|
||||
->with('myMessage');
|
||||
|
||||
$this->assertFalse($this->validator->isValid('', $constraint));
|
||||
$this->validator->isValid('', $constraint);
|
||||
}
|
||||
|
||||
public function testFalseIsInvalid()
|
||||
@ -90,7 +90,7 @@ class NotBlankValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->method('addViolation')
|
||||
->with('myMessage');
|
||||
|
||||
$this->assertFalse($this->validator->isValid(false, $constraint));
|
||||
$this->validator->isValid(false, $constraint);
|
||||
}
|
||||
|
||||
public function testEmptyArrayIsInvalid()
|
||||
@ -103,7 +103,7 @@ class NotBlankValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->method('addViolation')
|
||||
->with('myMessage');
|
||||
|
||||
$this->assertFalse($this->validator->isValid(array(), $constraint));
|
||||
$this->validator->isValid(array(), $constraint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ class NotNullValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class NotNullValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->with('myMessage', array(
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid(null, $constraint));
|
||||
$this->validator->isValid(null, $constraint);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class NullValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class NullValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $value,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($value, $constraint));
|
||||
$this->validator->isValid($value, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidValues()
|
||||
|
@ -37,7 +37,7 @@ class RegexValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class RegexValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class RegexValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->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 @@ class RegexValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $value,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($value, $constraint));
|
||||
$this->validator->isValid($value, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidValues()
|
||||
|
@ -37,7 +37,7 @@ class SizeLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class SizeLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class SizeLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->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 @@ class SizeLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->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 @@ class SizeLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ limit }}' => 5,
|
||||
), null, 5);
|
||||
|
||||
$this->assertFalse($this->validator->isValid('1234', $constraint));
|
||||
$this->validator->isValid('1234', $constraint);
|
||||
}
|
||||
|
||||
public function testMaxMessageIsSet()
|
||||
@ -149,7 +149,7 @@ class SizeLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ limit }}' => 10,
|
||||
), null, 10);
|
||||
|
||||
$this->assertFalse($this->validator->isValid('12345678901', $constraint));
|
||||
$this->validator->isValid('12345678901', $constraint);
|
||||
}
|
||||
|
||||
public function testExactMessageIsSet()
|
||||
@ -167,6 +167,6 @@ class SizeLengthValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ limit }}' => 5,
|
||||
), null, 5);
|
||||
|
||||
$this->assertFalse($this->validator->isValid('1234', $constraint));
|
||||
$this->validator->isValid('1234', $constraint);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class SizeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class SizeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->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 @@ class SizeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->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 @@ class SizeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ limit }}' => 10,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid(9, $constraint));
|
||||
$this->validator->isValid(9, $constraint);
|
||||
}
|
||||
|
||||
public function testMaxMessageIsSet()
|
||||
@ -116,6 +116,6 @@ class SizeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ limit }}' => 20,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid(21, $constraint));
|
||||
$this->validator->isValid(21, $constraint);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class TimeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TimeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TimeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TimeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TimeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $time,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($time, $constraint));
|
||||
$this->validator->isValid($time, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidTimes()
|
||||
|
@ -37,7 +37,7 @@ class TrueValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TrueValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TrueValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
->with('myMessage', array(
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid(false, $constraint));
|
||||
$this->validator->isValid(false, $constraint);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class TypeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TypeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class TypeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$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 @@ class TypeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ type }}' => $type,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($value, $constraint));
|
||||
$this->validator->isValid($value, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidValues()
|
||||
|
@ -37,7 +37,7 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->context->expects($this->never())
|
||||
->method('addViolation');
|
||||
|
||||
$this->assertTrue($this->validator->isValid('', new Url()));
|
||||
$this->validator->isValid('', new Url());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,7 +64,7 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'{{ value }}' => $url,
|
||||
));
|
||||
|
||||
$this->assertFalse($this->validator->isValid($url, $constraint));
|
||||
$this->validator->isValid($url, $constraint);
|
||||
}
|
||||
|
||||
public function getInvalidUrls()
|
||||
@ -154,7 +154,7 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
'protocols' => array('ftp', 'file', 'git')
|
||||
));
|
||||
|
||||
$this->assertTrue($this->validator->isValid($url, $constraint));
|
||||
$this->validator->isValid($url, $constraint);
|
||||
}
|
||||
|
||||
public function getValidCustomUrls()
|
||||
|
@ -31,9 +31,9 @@ class ConstraintAValidator extends ConstraintValidator
|
||||
if ('VALID' != $value) {
|
||||
$this->context->addViolation('message', array('param' => 'value'));
|
||||
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ class FailingConstraintValidator extends ConstraintValidator
|
||||
{
|
||||
$this->context->addViolation($constraint->message, array());
|
||||
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user