[Validator] Added extensive test coverage for the constraint validators for the different APIs
This commit is contained in:
parent
8e461af756
commit
7504448ee7
@ -44,9 +44,7 @@ class AllValidator extends ConstraintValidator
|
|||||||
$validator = $context->getValidator()->inContext($context);
|
$validator = $context->getValidator()->inContext($context);
|
||||||
|
|
||||||
foreach ($value as $key => $element) {
|
foreach ($value as $key => $element) {
|
||||||
foreach ($constraint->constraints as $constr) {
|
$validator->atPath('['.$key.']')->validate($element, $constraint->constraints, $group);
|
||||||
$validator->atPath('['.$key.']')->validate($element, $constr, $group);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,18 +53,20 @@ class CollectionValidator extends ConstraintValidator
|
|||||||
$validator = $context->getValidator()->inContext($context);
|
$validator = $context->getValidator()->inContext($context);
|
||||||
|
|
||||||
foreach ($constraint->fields as $field => $fieldConstraint) {
|
foreach ($constraint->fields as $field => $fieldConstraint) {
|
||||||
if (
|
|
||||||
// bug fix issue #2779
|
// bug fix issue #2779
|
||||||
(is_array($value) && array_key_exists($field, $value)) ||
|
$existsInArray = is_array($value) && array_key_exists($field, $value);
|
||||||
($value instanceof \ArrayAccess && $value->offsetExists($field))
|
$existsInArrayAccess = $value instanceof \ArrayAccess && $value->offsetExists($field);
|
||||||
) {
|
|
||||||
foreach ($fieldConstraint->constraints as $constr) {
|
if ($existsInArray || $existsInArrayAccess) {
|
||||||
$validator->atPath('['.$field.']')->validate($value[$field], $constr, $group);
|
if (count($fieldConstraint->constraints) > 0) {
|
||||||
|
$validator->atPath('['.$field.']')
|
||||||
|
->validate($value[$field], $fieldConstraint->constraints, $group);
|
||||||
}
|
}
|
||||||
} elseif (!$fieldConstraint instanceof Optional && !$constraint->allowMissingFields) {
|
} elseif (!$fieldConstraint instanceof Optional && !$constraint->allowMissingFields) {
|
||||||
$context->buildViolation($constraint->missingFieldsMessage)
|
$context->buildViolation($constraint->missingFieldsMessage)
|
||||||
->atPath('['.$field.']')
|
->atPath('['.$field.']')
|
||||||
->setParameter('{{ field }}', $field)
|
->setParameter('{{ field }}', $field)
|
||||||
|
->setInvalidValue(null)
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,6 +77,7 @@ class CollectionValidator extends ConstraintValidator
|
|||||||
$context->buildViolation($constraint->extraFieldsMessage)
|
$context->buildViolation($constraint->extraFieldsMessage)
|
||||||
->atPath('['.$field.']')
|
->atPath('['.$field.']')
|
||||||
->setParameter('{{ field }}', $field)
|
->setParameter('{{ field }}', $field)
|
||||||
|
->setInvalidValue($fieldValue)
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ class CountValidator extends ConstraintValidator
|
|||||||
$this->context->buildViolation($constraint->exactMessage)
|
$this->context->buildViolation($constraint->exactMessage)
|
||||||
->setParameter('{{ count }}', $count)
|
->setParameter('{{ count }}', $count)
|
||||||
->setParameter('{{ limit }}', $constraint->min)
|
->setParameter('{{ limit }}', $constraint->min)
|
||||||
->setValue($value)
|
->setInvalidValue($value)
|
||||||
->setPlural((int) $constraint->min)
|
->setPlural((int) $constraint->min)
|
||||||
->addViolation();
|
->addViolation();
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class CountValidator extends ConstraintValidator
|
|||||||
$this->context->buildViolation($constraint->maxMessage)
|
$this->context->buildViolation($constraint->maxMessage)
|
||||||
->setParameter('{{ count }}', $count)
|
->setParameter('{{ count }}', $count)
|
||||||
->setParameter('{{ limit }}', $constraint->max)
|
->setParameter('{{ limit }}', $constraint->max)
|
||||||
->setValue($value)
|
->setInvalidValue($value)
|
||||||
->setPlural((int) $constraint->max)
|
->setPlural((int) $constraint->max)
|
||||||
->addViolation();
|
->addViolation();
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class CountValidator extends ConstraintValidator
|
|||||||
$this->context->buildViolation($constraint->minMessage)
|
$this->context->buildViolation($constraint->minMessage)
|
||||||
->setParameter('{{ count }}', $count)
|
->setParameter('{{ count }}', $count)
|
||||||
->setParameter('{{ limit }}', $constraint->min)
|
->setParameter('{{ limit }}', $constraint->min)
|
||||||
->setValue($value)
|
->setInvalidValue($value)
|
||||||
->setPlural((int) $constraint->min)
|
->setPlural((int) $constraint->min)
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
|
@ -43,9 +43,7 @@ class LegacyAllValidator extends ConstraintValidator
|
|||||||
$group = $context->getGroup();
|
$group = $context->getGroup();
|
||||||
|
|
||||||
foreach ($value as $key => $element) {
|
foreach ($value as $key => $element) {
|
||||||
foreach ($constraint->constraints as $constr) {
|
$context->validateValue($element, $constraint->constraints, '['.$key.']', $group);
|
||||||
$context->validateValue($element, $constr, '['.$key.']', $group);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,13 +70,13 @@ class LegacyChoiceValidator extends ConstraintValidator
|
|||||||
$count = count($value);
|
$count = count($value);
|
||||||
|
|
||||||
if ($constraint->min !== null && $count < $constraint->min) {
|
if ($constraint->min !== null && $count < $constraint->min) {
|
||||||
$this->context->addViolation($constraint->minMessage, array('{{ limit }}' => $constraint->min), null, (int) $constraint->min);
|
$this->context->addViolation($constraint->minMessage, array('{{ limit }}' => $constraint->min), $value, (int) $constraint->min);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($constraint->max !== null && $count > $constraint->max) {
|
if ($constraint->max !== null && $count > $constraint->max) {
|
||||||
$this->context->addViolation($constraint->maxMessage, array('{{ limit }}' => $constraint->max), null, (int) $constraint->max);
|
$this->context->addViolation($constraint->maxMessage, array('{{ limit }}' => $constraint->max), $value, (int) $constraint->max);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -52,13 +52,13 @@ class LegacyCollectionValidator extends ConstraintValidator
|
|||||||
$group = $context->getGroup();
|
$group = $context->getGroup();
|
||||||
|
|
||||||
foreach ($constraint->fields as $field => $fieldConstraint) {
|
foreach ($constraint->fields as $field => $fieldConstraint) {
|
||||||
if (
|
|
||||||
// bug fix issue #2779
|
// bug fix issue #2779
|
||||||
(is_array($value) && array_key_exists($field, $value)) ||
|
$existsInArray = is_array($value) && array_key_exists($field, $value);
|
||||||
($value instanceof \ArrayAccess && $value->offsetExists($field))
|
$existsInArrayAccess = $value instanceof \ArrayAccess && $value->offsetExists($field);
|
||||||
) {
|
|
||||||
foreach ($fieldConstraint->constraints as $constr) {
|
if ($existsInArray || $existsInArrayAccess) {
|
||||||
$context->validateValue($value[$field], $constr, '['.$field.']', $group);
|
if (count($fieldConstraint->constraints) > 0) {
|
||||||
|
$context->validateValue($value[$field], $fieldConstraint->constraints, '['.$field.']', $group);
|
||||||
}
|
}
|
||||||
} elseif (!$fieldConstraint instanceof Optional && !$constraint->allowMissingFields) {
|
} elseif (!$fieldConstraint instanceof Optional && !$constraint->allowMissingFields) {
|
||||||
$context->addViolationAt('['.$field.']', $constraint->missingFieldsMessage, array(
|
$context->addViolationAt('['.$field.']', $constraint->missingFieldsMessage, array(
|
||||||
|
@ -51,7 +51,7 @@ class LengthValidator extends ConstraintValidator
|
|||||||
$this->context->buildViolation($constraint->exactMessage)
|
$this->context->buildViolation($constraint->exactMessage)
|
||||||
->setParameter('{{ value }}', $stringValue)
|
->setParameter('{{ value }}', $stringValue)
|
||||||
->setParameter('{{ limit }}', $constraint->min)
|
->setParameter('{{ limit }}', $constraint->min)
|
||||||
->setValue($value)
|
->setInvalidValue($value)
|
||||||
->setPlural((int) $constraint->min)
|
->setPlural((int) $constraint->min)
|
||||||
->addViolation();
|
->addViolation();
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ class LengthValidator extends ConstraintValidator
|
|||||||
$this->context->buildViolation($constraint->maxMessage)
|
$this->context->buildViolation($constraint->maxMessage)
|
||||||
->setParameter('{{ value }}', $stringValue)
|
->setParameter('{{ value }}', $stringValue)
|
||||||
->setParameter('{{ limit }}', $constraint->max)
|
->setParameter('{{ limit }}', $constraint->max)
|
||||||
->setValue($value)
|
->setInvalidValue($value)
|
||||||
->setPlural((int) $constraint->max)
|
->setPlural((int) $constraint->max)
|
||||||
->addViolation();
|
->addViolation();
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ class LengthValidator extends ConstraintValidator
|
|||||||
$this->context->buildViolation($constraint->minMessage)
|
$this->context->buildViolation($constraint->minMessage)
|
||||||
->setParameter('{{ value }}', $stringValue)
|
->setParameter('{{ value }}', $stringValue)
|
||||||
->setParameter('{{ limit }}', $constraint->min)
|
->setParameter('{{ limit }}', $constraint->min)
|
||||||
->setValue($value)
|
->setInvalidValue($value)
|
||||||
->setPlural((int) $constraint->min)
|
->setPlural((int) $constraint->min)
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
|
@ -32,30 +32,15 @@ class ComparisonTest_Class
|
|||||||
/**
|
/**
|
||||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||||
*/
|
*/
|
||||||
abstract class AbstractComparisonValidatorTestCase extends \PHPUnit_Framework_TestCase
|
abstract class AbstractComparisonValidatorTestCase extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
private $validator;
|
|
||||||
private $context;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
|
||||||
$this->validator = $this->createValidator();
|
|
||||||
$this->context = $this->getMockBuilder('Symfony\Component\Validator\ExecutionContext')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return AbstractComparisonValidator
|
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||||
*/
|
*/
|
||||||
abstract protected function createValidator();
|
|
||||||
|
|
||||||
public function testThrowsConstraintExceptionIfNoValueOrProperty()
|
public function testThrowsConstraintExceptionIfNoValueOrProperty()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('Symfony\Component\Validator\Exception\ConstraintDefinitionException');
|
|
||||||
|
|
||||||
$comparison = $this->createConstraint(array());
|
$comparison = $this->createConstraint(array());
|
||||||
|
|
||||||
$this->validator->validate('some value', $comparison);
|
$this->validator->validate('some value', $comparison);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,16 +51,11 @@ abstract class AbstractComparisonValidatorTestCase extends \PHPUnit_Framework_Te
|
|||||||
*/
|
*/
|
||||||
public function testValidComparisonToValue($dirtyValue, $comparisonValue)
|
public function testValidComparisonToValue($dirtyValue, $comparisonValue)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$constraint = $this->createConstraint(array('value' => $comparisonValue));
|
$constraint = $this->createConstraint(array('value' => $comparisonValue));
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
|
||||||
->method('getPropertyPath')
|
|
||||||
->will($this->returnValue('property1'));
|
|
||||||
|
|
||||||
$this->validator->validate($dirtyValue, $constraint);
|
$this->validator->validate($dirtyValue, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,19 +75,13 @@ abstract class AbstractComparisonValidatorTestCase extends \PHPUnit_Framework_Te
|
|||||||
$constraint = $this->createConstraint(array('value' => $comparedValue));
|
$constraint = $this->createConstraint(array('value' => $comparedValue));
|
||||||
$constraint->message = 'Constraint Message';
|
$constraint->message = 'Constraint Message';
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
$this->validator->validate($dirtyValue, $constraint);
|
||||||
->method('getPropertyPath')
|
|
||||||
->will($this->returnValue('property1'));
|
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->assertViolation('Constraint Message', array(
|
||||||
->method('addViolation')
|
|
||||||
->with('Constraint Message', array(
|
|
||||||
'{{ value }}' => $comparedValueString,
|
'{{ value }}' => $comparedValueString,
|
||||||
'{{ compared_value }}' => $comparedValueString,
|
'{{ compared_value }}' => $comparedValueString,
|
||||||
'{{ compared_value_type }}' => $comparedValueType
|
'{{ compared_value_type }}' => $comparedValueType
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($dirtyValue, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,298 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\ConstraintValidatorInterface;
|
||||||
|
use Symfony\Component\Validator\ConstraintViolation;
|
||||||
|
use Symfony\Component\Validator\Context\ExecutionContext;
|
||||||
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
use Symfony\Component\Validator\Context\LegacyExecutionContext;
|
||||||
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
|
use Symfony\Component\Validator\Mapping\PropertyMetadata;
|
||||||
|
use Symfony\Component\Validator\Tests\Fixtures\StubGlobalExecutionContext;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
abstract class AbstractConstraintValidatorTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var ExecutionContextInterface
|
||||||
|
*/
|
||||||
|
protected $context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ConstraintValidatorInterface
|
||||||
|
*/
|
||||||
|
protected $validator;
|
||||||
|
|
||||||
|
protected $group;
|
||||||
|
|
||||||
|
protected $metadata;
|
||||||
|
|
||||||
|
protected $object;
|
||||||
|
|
||||||
|
protected $value;
|
||||||
|
|
||||||
|
protected $root;
|
||||||
|
|
||||||
|
protected $propertyPath;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->group = 'MyGroup';
|
||||||
|
$this->metadata = null;
|
||||||
|
$this->object = null;
|
||||||
|
$this->value = 'InvalidValue';
|
||||||
|
$this->root = 'root';
|
||||||
|
$this->propertyPath = 'property.path';
|
||||||
|
$this->context = $this->createContext();
|
||||||
|
$this->validator = $this->createValidator();
|
||||||
|
$this->validator->initialize($this->context);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createContext()
|
||||||
|
{
|
||||||
|
$translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface');
|
||||||
|
|
||||||
|
if (Validation::API_VERSION_2_4 === $this->getApiVersion()) {
|
||||||
|
return $this->getMockBuilder('Symfony\Component\Validator\ExecutionContext')
|
||||||
|
->setConstructorArgs(array(
|
||||||
|
new StubGlobalExecutionContext($this->root),
|
||||||
|
$translator,
|
||||||
|
null,
|
||||||
|
$this->metadata,
|
||||||
|
$this->value,
|
||||||
|
$this->group,
|
||||||
|
$this->propertyPath
|
||||||
|
))
|
||||||
|
->setMethods(array('validate', 'validateValue'))
|
||||||
|
->getMock();
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
|
||||||
|
$contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface');
|
||||||
|
|
||||||
|
switch ($this->getApiVersion()) {
|
||||||
|
case Validation::API_VERSION_2_5:
|
||||||
|
$context = new ExecutionContext(
|
||||||
|
$validator,
|
||||||
|
$this->root,
|
||||||
|
$translator
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case Validation::API_VERSION_2_5_BC:
|
||||||
|
$context = new LegacyExecutionContext(
|
||||||
|
$validator,
|
||||||
|
$this->root,
|
||||||
|
$this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'),
|
||||||
|
$translator
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new \RuntimeException('Invalid API version');
|
||||||
|
}
|
||||||
|
|
||||||
|
$context->setGroup($this->group);
|
||||||
|
$context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
||||||
|
|
||||||
|
$validator->expects($this->any())
|
||||||
|
->method('inContext')
|
||||||
|
->with($context)
|
||||||
|
->will($this->returnValue($contextualValidator));
|
||||||
|
|
||||||
|
return $context;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createViolation($message, array $parameters = array(), $propertyPath = 'property.path', $invalidValue = 'InvalidValue', $plural = null, $code = null)
|
||||||
|
{
|
||||||
|
return new ConstraintViolation(
|
||||||
|
null,
|
||||||
|
$message,
|
||||||
|
$parameters,
|
||||||
|
$this->root,
|
||||||
|
$propertyPath,
|
||||||
|
$invalidValue,
|
||||||
|
$plural,
|
||||||
|
$code
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setGroup($group)
|
||||||
|
{
|
||||||
|
$this->group = $group;
|
||||||
|
|
||||||
|
switch ($this->getApiVersion()) {
|
||||||
|
case Validation::API_VERSION_2_4:
|
||||||
|
$this->context = $this->createContext();
|
||||||
|
$this->validator->initialize($this->context);
|
||||||
|
break;
|
||||||
|
case Validation::API_VERSION_2_5:
|
||||||
|
case Validation::API_VERSION_2_5_BC:
|
||||||
|
$this->context->setGroup($group);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setObject($object)
|
||||||
|
{
|
||||||
|
$this->object = $object;
|
||||||
|
$this->metadata = is_object($object)
|
||||||
|
? new ClassMetadata(get_class($object))
|
||||||
|
: null;
|
||||||
|
|
||||||
|
switch ($this->getApiVersion()) {
|
||||||
|
case Validation::API_VERSION_2_4:
|
||||||
|
$this->context = $this->createContext();
|
||||||
|
$this->validator->initialize($this->context);
|
||||||
|
break;
|
||||||
|
case Validation::API_VERSION_2_5:
|
||||||
|
case Validation::API_VERSION_2_5_BC:
|
||||||
|
$this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setProperty($object, $property)
|
||||||
|
{
|
||||||
|
$this->object = $object;
|
||||||
|
$this->metadata = is_object($object)
|
||||||
|
? new PropertyMetadata(get_class($object), $property)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
switch ($this->getApiVersion()) {
|
||||||
|
case Validation::API_VERSION_2_4:
|
||||||
|
$this->context = $this->createContext();
|
||||||
|
$this->validator->initialize($this->context);
|
||||||
|
break;
|
||||||
|
case Validation::API_VERSION_2_5:
|
||||||
|
case Validation::API_VERSION_2_5_BC:
|
||||||
|
$this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setValue($value)
|
||||||
|
{
|
||||||
|
$this->value = $value;
|
||||||
|
|
||||||
|
switch ($this->getApiVersion()) {
|
||||||
|
case Validation::API_VERSION_2_4:
|
||||||
|
$this->context = $this->createContext();
|
||||||
|
$this->validator->initialize($this->context);
|
||||||
|
break;
|
||||||
|
case Validation::API_VERSION_2_5:
|
||||||
|
case Validation::API_VERSION_2_5_BC:
|
||||||
|
$this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setRoot($root)
|
||||||
|
{
|
||||||
|
$this->root = $root;
|
||||||
|
$this->context = $this->createContext();
|
||||||
|
$this->validator->initialize($this->context);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setPropertyPath($propertyPath)
|
||||||
|
{
|
||||||
|
$this->propertyPath = $propertyPath;
|
||||||
|
|
||||||
|
switch ($this->getApiVersion()) {
|
||||||
|
case Validation::API_VERSION_2_4:
|
||||||
|
$this->context = $this->createContext();
|
||||||
|
$this->validator->initialize($this->context);
|
||||||
|
break;
|
||||||
|
case Validation::API_VERSION_2_5:
|
||||||
|
case Validation::API_VERSION_2_5_BC:
|
||||||
|
$this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function expectValidateAt($i, $propertyPath, $value, $group)
|
||||||
|
{
|
||||||
|
switch ($this->getApiVersion()) {
|
||||||
|
case Validation::API_VERSION_2_4:
|
||||||
|
$this->context->expects($this->at($i))
|
||||||
|
->method('validate')
|
||||||
|
->with($value, $propertyPath, $group);
|
||||||
|
break;
|
||||||
|
case Validation::API_VERSION_2_5:
|
||||||
|
case Validation::API_VERSION_2_5_BC:
|
||||||
|
$validator = $this->context->getValidator()->inContext($this->context);
|
||||||
|
$validator->expects($this->at(2 * $i))
|
||||||
|
->method('atPath')
|
||||||
|
->with($propertyPath)
|
||||||
|
->will($this->returnValue($validator));
|
||||||
|
$validator->expects($this->at(2 * $i + 1))
|
||||||
|
->method('validate')
|
||||||
|
->with($value, array(), $group);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function expectValidateValueAt($i, $propertyPath, $value, $constraints, $group)
|
||||||
|
{
|
||||||
|
switch ($this->getApiVersion()) {
|
||||||
|
case Validation::API_VERSION_2_4:
|
||||||
|
$this->context->expects($this->at($i))
|
||||||
|
->method('validateValue')
|
||||||
|
->with($value, $constraints, $propertyPath, $group);
|
||||||
|
break;
|
||||||
|
case Validation::API_VERSION_2_5:
|
||||||
|
case Validation::API_VERSION_2_5_BC:
|
||||||
|
$contextualValidator = $this->context->getValidator()->inContext($this->context);
|
||||||
|
$contextualValidator->expects($this->at(2 * $i))
|
||||||
|
->method('atPath')
|
||||||
|
->with($propertyPath)
|
||||||
|
->will($this->returnValue($contextualValidator));
|
||||||
|
$contextualValidator->expects($this->at(2 * $i + 1))
|
||||||
|
->method('validate')
|
||||||
|
->with($value, $constraints, $group);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function assertNoViolation()
|
||||||
|
{
|
||||||
|
$this->assertCount(0, $this->context->getViolations());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function assertViolation($message, array $parameters = array(), $propertyPath = 'property.path', $invalidValue = 'InvalidValue', $plural = null, $code = null)
|
||||||
|
{
|
||||||
|
$violations = $this->context->getViolations();
|
||||||
|
|
||||||
|
$this->assertCount(1, $violations);
|
||||||
|
$this->assertEquals($this->createViolation($message, $parameters, $propertyPath, $invalidValue, $plural, $code), $violations[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function assertViolations(array $expected)
|
||||||
|
{
|
||||||
|
$violations = $this->context->getViolations();
|
||||||
|
|
||||||
|
$this->assertCount(count($expected), $violations);
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
foreach ($expected as $violation) {
|
||||||
|
$this->assertEquals($violation, $violations[$i++]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract protected function getApiVersion();
|
||||||
|
|
||||||
|
abstract protected function createValidator();
|
||||||
|
}
|
@ -15,35 +15,25 @@ use Symfony\Component\Validator\Constraints\All;
|
|||||||
use Symfony\Component\Validator\Constraints\AllValidator;
|
use Symfony\Component\Validator\Constraints\AllValidator;
|
||||||
use Symfony\Component\Validator\Constraints\NotNull;
|
use Symfony\Component\Validator\Constraints\NotNull;
|
||||||
use Symfony\Component\Validator\Constraints\Range;
|
use Symfony\Component\Validator\Constraints\Range;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class AllValidatorTest extends \PHPUnit_Framework_TestCase
|
class AllValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new AllValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
|
||||||
->method('getGroup')
|
|
||||||
->will($this->returnValue('MyGroup'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
$this->validator = null;
|
return new AllValidator();
|
||||||
$this->context = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new All(new Range(array('min' => 4))));
|
$this->validator->validate(null, new All(new Range(array('min' => 4))));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,18 +51,15 @@ class AllValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$constraint = new Range(array('min' => 4));
|
$constraint = new Range(array('min' => 4));
|
||||||
|
|
||||||
$i = 1;
|
$i = 0;
|
||||||
|
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
$this->context->expects($this->at($i++))
|
$this->expectValidateValueAt($i++, '['.$key.']', $value, array($constraint), 'MyGroup');
|
||||||
->method('validateValue')
|
|
||||||
->with($value, $constraint, '['.$key.']', 'MyGroup');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($array, new All($constraint));
|
$this->validator->validate($array, new All($constraint));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,21 +71,16 @@ class AllValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$constraint2 = new NotNull();
|
$constraint2 = new NotNull();
|
||||||
|
|
||||||
$constraints = array($constraint1, $constraint2);
|
$constraints = array($constraint1, $constraint2);
|
||||||
$i = 1;
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
$this->context->expects($this->at($i++))
|
$this->expectValidateValueAt($i++, '['.$key.']', $value, array($constraint1, $constraint2), 'MyGroup');
|
||||||
->method('validateValue')
|
|
||||||
->with($value, $constraint1, '['.$key.']', 'MyGroup');
|
|
||||||
$this->context->expects($this->at($i++))
|
|
||||||
->method('validateValue')
|
|
||||||
->with($value, $constraint2, '['.$key.']', 'MyGroup');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($array, new All($constraints));
|
$this->validator->validate($array, new All($constraints));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidArguments()
|
public function getValidArguments()
|
||||||
|
@ -13,39 +13,33 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Blank;
|
use Symfony\Component\Validator\Constraints\Blank;
|
||||||
use Symfony\Component\Validator\Constraints\BlankValidator;
|
use Symfony\Component\Validator\Constraints\BlankValidator;
|
||||||
|
use Symfony\Component\Validator\ConstraintViolation;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class BlankValidatorTest extends \PHPUnit_Framework_TestCase
|
class BlankValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new BlankValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
$this->context = null;
|
return new BlankValidator();
|
||||||
$this->validator = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new Blank());
|
$this->validator->validate(null, new Blank());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBlankIsValid()
|
public function testBlankIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', new Blank());
|
$this->validator->validate('', new Blank());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,13 +51,12 @@ class BlankValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage'
|
'message' => 'myMessage'
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
|
||||||
'{{ value }}' => $value,
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation(
|
||||||
|
'myMessage',
|
||||||
|
array('{{ value }}' => $value)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidValues()
|
public function getInvalidValues()
|
||||||
|
@ -14,13 +14,14 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
use Symfony\Component\Validator\Constraints\Callback;
|
use Symfony\Component\Validator\Constraints\Callback;
|
||||||
use Symfony\Component\Validator\Constraints\CallbackValidator;
|
use Symfony\Component\Validator\Constraints\CallbackValidator;
|
||||||
use Symfony\Component\Validator\ExecutionContext;
|
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class CallbackValidatorTest_Class
|
class CallbackValidatorTest_Class
|
||||||
{
|
{
|
||||||
public static function validateCallback($object, ExecutionContext $context)
|
public static function validateCallback($object, ExecutionContextInterface $context)
|
||||||
{
|
{
|
||||||
$context->addViolation('Callback message', array('{{ value }}' => 'foobar'), 'invalidValue');
|
$context->addViolation('Callback message', array('{{ value }}' => 'foobar'));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -28,45 +29,38 @@ class CallbackValidatorTest_Class
|
|||||||
|
|
||||||
class CallbackValidatorTest_Object
|
class CallbackValidatorTest_Object
|
||||||
{
|
{
|
||||||
public function validate(ExecutionContext $context)
|
public function validate(ExecutionContextInterface $context)
|
||||||
{
|
{
|
||||||
$context->addViolation('My message', array('{{ value }}' => 'foobar'), 'invalidValue');
|
$context->addViolation('My message', array('{{ value }}' => 'foobar'));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function validateStatic($object, ExecutionContext $context)
|
public static function validateStatic($object, ExecutionContextInterface $context)
|
||||||
{
|
{
|
||||||
$context->addViolation('Static message', array('{{ value }}' => 'baz'), 'otherInvalidValue');
|
$context->addViolation('Static message', array('{{ value }}' => 'baz'));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
class CallbackValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new CallbackValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
$this->context = null;
|
return new CallbackValidator();
|
||||||
$this->validator = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new Callback(array('foo')));
|
$this->validator->validate(null, new Callback(array('foo')));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSingleMethod()
|
public function testSingleMethod()
|
||||||
@ -74,13 +68,11 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$object = new CallbackValidatorTest_Object();
|
$object = new CallbackValidatorTest_Object();
|
||||||
$constraint = new Callback('validate');
|
$constraint = new Callback('validate');
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($object, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('My message', array(
|
$this->assertViolation('My message', array(
|
||||||
'{{ value }}' => 'foobar',
|
'{{ value }}' => 'foobar',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSingleMethodExplicitName()
|
public function testSingleMethodExplicitName()
|
||||||
@ -88,13 +80,11 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$object = new CallbackValidatorTest_Object();
|
$object = new CallbackValidatorTest_Object();
|
||||||
$constraint = new Callback(array('callback' => 'validate'));
|
$constraint = new Callback(array('callback' => 'validate'));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($object, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('My message', array(
|
$this->assertViolation('My message', array(
|
||||||
'{{ value }}' => 'foobar',
|
'{{ value }}' => 'foobar',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSingleStaticMethod()
|
public function testSingleStaticMethod()
|
||||||
@ -102,68 +92,60 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$object = new CallbackValidatorTest_Object();
|
$object = new CallbackValidatorTest_Object();
|
||||||
$constraint = new Callback('validateStatic');
|
$constraint = new Callback('validateStatic');
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($object, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('Static message', array(
|
$this->assertViolation('Static message', array(
|
||||||
'{{ value }}' => 'baz',
|
'{{ value }}' => 'baz',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testClosure()
|
public function testClosure()
|
||||||
{
|
{
|
||||||
$object = new CallbackValidatorTest_Object();
|
$object = new CallbackValidatorTest_Object();
|
||||||
$constraint = new Callback(function ($object, ExecutionContext $context) {
|
$constraint = new Callback(function ($object, ExecutionContextInterface $context) {
|
||||||
$context->addViolation('My message', array('{{ value }}' => 'foobar'), 'invalidValue');
|
$context->addViolation('My message', array('{{ value }}' => 'foobar'));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($object, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('My message', array(
|
$this->assertViolation('My message', array(
|
||||||
'{{ value }}' => 'foobar',
|
'{{ value }}' => 'foobar',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testClosureNullObject()
|
public function testClosureNullObject()
|
||||||
{
|
{
|
||||||
$constraint = new Callback(function ($object, ExecutionContext $context) {
|
$constraint = new Callback(function ($object, ExecutionContextInterface $context) {
|
||||||
$context->addViolation('My message', array('{{ value }}' => 'foobar'), 'invalidValue');
|
$context->addViolation('My message', array('{{ value }}' => 'foobar'));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate(null, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('My message', array(
|
$this->assertViolation('My message', array(
|
||||||
'{{ value }}' => 'foobar',
|
'{{ value }}' => 'foobar',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate(null, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testClosureExplicitName()
|
public function testClosureExplicitName()
|
||||||
{
|
{
|
||||||
$object = new CallbackValidatorTest_Object();
|
$object = new CallbackValidatorTest_Object();
|
||||||
$constraint = new Callback(array(
|
$constraint = new Callback(array(
|
||||||
'callback' => function ($object, ExecutionContext $context) {
|
'callback' => function ($object, ExecutionContextInterface $context) {
|
||||||
$context->addViolation('My message', array('{{ value }}' => 'foobar'), 'invalidValue');
|
$context->addViolation('My message', array('{{ value }}' => 'foobar'));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($object, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('My message', array(
|
$this->assertViolation('My message', array(
|
||||||
'{{ value }}' => 'foobar',
|
'{{ value }}' => 'foobar',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testArrayCallable()
|
public function testArrayCallable()
|
||||||
@ -171,26 +153,22 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$object = new CallbackValidatorTest_Object();
|
$object = new CallbackValidatorTest_Object();
|
||||||
$constraint = new Callback(array(__CLASS__.'_Class', 'validateCallback'));
|
$constraint = new Callback(array(__CLASS__.'_Class', 'validateCallback'));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($object, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('Callback message', array(
|
$this->assertViolation('Callback message', array(
|
||||||
'{{ value }}' => 'foobar',
|
'{{ value }}' => 'foobar',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testArrayCallableNullObject()
|
public function testArrayCallableNullObject()
|
||||||
{
|
{
|
||||||
$constraint = new Callback(array(__CLASS__.'_Class', 'validateCallback'));
|
$constraint = new Callback(array(__CLASS__.'_Class', 'validateCallback'));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate(null, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('Callback message', array(
|
$this->assertViolation('Callback message', array(
|
||||||
'{{ value }}' => 'foobar',
|
'{{ value }}' => 'foobar',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate(null, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testArrayCallableExplicitName()
|
public function testArrayCallableExplicitName()
|
||||||
@ -200,13 +178,11 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'callback' => array(__CLASS__.'_Class', 'validateCallback'),
|
'callback' => array(__CLASS__.'_Class', 'validateCallback'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($object, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('Callback message', array(
|
$this->assertViolation('Callback message', array(
|
||||||
'{{ value }}' => 'foobar',
|
'{{ value }}' => 'foobar',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BC with Symfony < 2.4
|
// BC with Symfony < 2.4
|
||||||
@ -215,13 +191,11 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$object = new CallbackValidatorTest_Object();
|
$object = new CallbackValidatorTest_Object();
|
||||||
$constraint = new Callback(array('validate'));
|
$constraint = new Callback(array('validate'));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($object, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('My message', array(
|
$this->assertViolation('My message', array(
|
||||||
'{{ value }}' => 'foobar',
|
'{{ value }}' => 'foobar',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BC with Symfony < 2.4
|
// BC with Symfony < 2.4
|
||||||
@ -230,13 +204,11 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$object = new CallbackValidatorTest_Object();
|
$object = new CallbackValidatorTest_Object();
|
||||||
$constraint = new Callback(array('methods' => array('validate')));
|
$constraint = new Callback(array('methods' => array('validate')));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($object, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('My message', array(
|
$this->assertViolation('My message', array(
|
||||||
'{{ value }}' => 'foobar',
|
'{{ value }}' => 'foobar',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BC with Symfony < 2.4
|
// BC with Symfony < 2.4
|
||||||
@ -245,18 +217,16 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$object = new CallbackValidatorTest_Object();
|
$object = new CallbackValidatorTest_Object();
|
||||||
$constraint = new Callback(array('validate', 'validateStatic'));
|
$constraint = new Callback(array('validate', 'validateStatic'));
|
||||||
|
|
||||||
$this->context->expects($this->at(0))
|
|
||||||
->method('addViolation')
|
|
||||||
->with('My message', array(
|
|
||||||
'{{ value }}' => 'foobar',
|
|
||||||
));
|
|
||||||
$this->context->expects($this->at(1))
|
|
||||||
->method('addViolation')
|
|
||||||
->with('Static message', array(
|
|
||||||
'{{ value }}' => 'baz',
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
$this->validator->validate($object, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolations(array(
|
||||||
|
$this->createViolation('My message', array(
|
||||||
|
'{{ value }}' => 'foobar',
|
||||||
|
)),
|
||||||
|
$this->createViolation('Static message', array(
|
||||||
|
'{{ value }}' => 'baz',
|
||||||
|
)),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// BC with Symfony < 2.4
|
// BC with Symfony < 2.4
|
||||||
@ -267,18 +237,16 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'methods' => array('validate', 'validateStatic'),
|
'methods' => array('validate', 'validateStatic'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->at(0))
|
|
||||||
->method('addViolation')
|
|
||||||
->with('My message', array(
|
|
||||||
'{{ value }}' => 'foobar',
|
|
||||||
));
|
|
||||||
$this->context->expects($this->at(1))
|
|
||||||
->method('addViolation')
|
|
||||||
->with('Static message', array(
|
|
||||||
'{{ value }}' => 'baz',
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
$this->validator->validate($object, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolations(array(
|
||||||
|
$this->createViolation('My message', array(
|
||||||
|
'{{ value }}' => 'foobar',
|
||||||
|
)),
|
||||||
|
$this->createViolation('Static message', array(
|
||||||
|
'{{ value }}' => 'baz',
|
||||||
|
)),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// BC with Symfony < 2.4
|
// BC with Symfony < 2.4
|
||||||
@ -289,13 +257,11 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(__CLASS__.'_Class', 'validateCallback')
|
array(__CLASS__.'_Class', 'validateCallback')
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($object, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('Callback message', array(
|
$this->assertViolation('Callback message', array(
|
||||||
'{{ value }}' => 'foobar',
|
'{{ value }}' => 'foobar',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BC with Symfony < 2.4
|
// BC with Symfony < 2.4
|
||||||
@ -306,13 +272,11 @@ class CallbackValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'methods' => array(array(__CLASS__.'_Class', 'validateCallback')),
|
'methods' => array(array(__CLASS__.'_Class', 'validateCallback')),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($object, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('Callback message', array(
|
$this->assertViolation('Callback message', array(
|
||||||
'{{ value }}' => 'foobar',
|
'{{ value }}' => 'foobar',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,39 +13,32 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\CardScheme;
|
use Symfony\Component\Validator\Constraints\CardScheme;
|
||||||
use Symfony\Component\Validator\Constraints\CardSchemeValidator;
|
use Symfony\Component\Validator\Constraints\CardSchemeValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class CardSchemeValidatorTest extends \PHPUnit_Framework_TestCase
|
class CardSchemeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new CardSchemeValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
$this->context = null;
|
return new CardSchemeValidator();
|
||||||
$this->validator = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new CardScheme(array('schemes' => array())));
|
$this->validator->validate(null, new CardScheme(array('schemes' => array())));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringIsValid()
|
public function testEmptyStringIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', new CardScheme(array('schemes' => array())));
|
$this->validator->validate('', new CardScheme(array('schemes' => array())));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,10 +46,9 @@ class CardSchemeValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidNumbers($scheme, $number)
|
public function testValidNumbers($scheme, $number)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($number, new CardScheme(array('schemes' => $scheme)));
|
$this->validator->validate($number, new CardScheme(array('schemes' => $scheme)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,10 +56,14 @@ class CardSchemeValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidNumbers($scheme, $number)
|
public function testInvalidNumbers($scheme, $number)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->once())
|
$constraint = new CardScheme(array(
|
||||||
->method('addViolation');
|
'schemes' => $scheme,
|
||||||
|
'message' => 'myMessage',
|
||||||
|
));
|
||||||
|
|
||||||
$this->validator->validate($number, new CardScheme(array('schemes' => $scheme)));
|
$this->validator->validate($number, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage', array());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidNumbers()
|
public function getValidNumbers()
|
||||||
|
@ -13,39 +13,31 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Choice;
|
use Symfony\Component\Validator\Constraints\Choice;
|
||||||
use Symfony\Component\Validator\Constraints\ChoiceValidator;
|
use Symfony\Component\Validator\Constraints\ChoiceValidator;
|
||||||
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
function choice_callback()
|
function choice_callback()
|
||||||
{
|
{
|
||||||
return array('foo', 'bar');
|
return array('foo', 'bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
class ChoiceValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
{
|
||||||
|
return Validation::API_VERSION_2_5;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new ChoiceValidator();
|
||||||
|
}
|
||||||
|
|
||||||
public static function staticCallback()
|
public static function staticCallback()
|
||||||
{
|
{
|
||||||
return array('foo', 'bar');
|
return array('foo', 'bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
|
||||||
$this->validator = new ChoiceValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
|
||||||
->method('getClassName')
|
|
||||||
->will($this->returnValue(__CLASS__));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function tearDown()
|
|
||||||
{
|
|
||||||
$this->context = null;
|
|
||||||
$this->validator = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||||
*/
|
*/
|
||||||
@ -61,10 +53,9 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new Choice(array('choices' => array('foo', 'bar'))));
|
$this->validator->validate(null, new Choice(array('choices' => array('foo', 'bar'))));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,20 +78,18 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$constraint = new Choice(array('choices' => array('foo', 'bar')));
|
$constraint = new Choice(array('choices' => array('foo', 'bar')));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('bar', $constraint);
|
$this->validator->validate('bar', $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidChoiceCallbackFunction()
|
public function testValidChoiceCallbackFunction()
|
||||||
{
|
{
|
||||||
$constraint = new Choice(array('callback' => __NAMESPACE__.'\choice_callback'));
|
$constraint = new Choice(array('callback' => __NAMESPACE__.'\choice_callback'));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('bar', $constraint);
|
$this->validator->validate('bar', $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidChoiceCallbackClosure()
|
public function testValidChoiceCallbackClosure()
|
||||||
@ -109,30 +98,30 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
return array('foo', 'bar');
|
return array('foo', 'bar');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('bar', $constraint);
|
$this->validator->validate('bar', $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidChoiceCallbackStaticMethod()
|
public function testValidChoiceCallbackStaticMethod()
|
||||||
{
|
{
|
||||||
$constraint = new Choice(array('callback' => array(__CLASS__, 'staticCallback')));
|
$constraint = new Choice(array('callback' => array(__CLASS__, 'staticCallback')));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('bar', $constraint);
|
$this->validator->validate('bar', $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidChoiceCallbackContextMethod()
|
public function testValidChoiceCallbackContextMethod()
|
||||||
{
|
{
|
||||||
|
// search $this for "staticCallback"
|
||||||
|
$this->setObject($this);
|
||||||
|
|
||||||
$constraint = new Choice(array('callback' => 'staticCallback'));
|
$constraint = new Choice(array('callback' => 'staticCallback'));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('bar', $constraint);
|
$this->validator->validate('bar', $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMultipleChoices()
|
public function testMultipleChoices()
|
||||||
@ -142,10 +131,9 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(array('baz', 'bar'), $constraint);
|
$this->validator->validate(array('baz', 'bar'), $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidChoice()
|
public function testInvalidChoice()
|
||||||
@ -155,13 +143,11 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
|
||||||
'{{ value }}' => 'baz',
|
|
||||||
), null, null);
|
|
||||||
|
|
||||||
$this->validator->validate('baz', $constraint);
|
$this->validator->validate('baz', $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage', array(
|
||||||
|
'{{ value }}' => 'baz',
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidChoiceMultiple()
|
public function testInvalidChoiceMultiple()
|
||||||
@ -172,13 +158,11 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate(array('foo', 'baz'), $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => 'baz',
|
'{{ value }}' => 'baz',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate(array('foo', 'baz'), $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTooFewChoices()
|
public function testTooFewChoices()
|
||||||
@ -190,13 +174,15 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'minMessage' => 'myMessage',
|
'minMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$value = array('foo');
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
|
||||||
'{{ limit }}' => 2,
|
|
||||||
), null, 2);
|
|
||||||
|
|
||||||
$this->validator->validate(array('foo'), $constraint);
|
$this->setValue($value);
|
||||||
|
|
||||||
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage', array(
|
||||||
|
'{{ limit }}' => 2,
|
||||||
|
), 'property.path', $value, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTooManyChoices()
|
public function testTooManyChoices()
|
||||||
@ -208,13 +194,15 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'maxMessage' => 'myMessage',
|
'maxMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$value = array('foo', 'bar', 'moo');
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
|
||||||
'{{ limit }}' => 2,
|
|
||||||
), null, 2);
|
|
||||||
|
|
||||||
$this->validator->validate(array('foo', 'bar', 'moo'), $constraint);
|
$this->setValue($value);
|
||||||
|
|
||||||
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage', array(
|
||||||
|
'{{ limit }}' => 2,
|
||||||
|
), 'property.path', $value, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNonStrict()
|
public function testNonStrict()
|
||||||
@ -224,11 +212,10 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'strict' => false,
|
'strict' => false,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('2', $constraint);
|
$this->validator->validate('2', $constraint);
|
||||||
$this->validator->validate(2, $constraint);
|
$this->validator->validate(2, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStrictAllowsExactValue()
|
public function testStrictAllowsExactValue()
|
||||||
@ -238,10 +225,9 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'strict' => true,
|
'strict' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(2, $constraint);
|
$this->validator->validate(2, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStrictDisallowsDifferentType()
|
public function testStrictDisallowsDifferentType()
|
||||||
@ -252,13 +238,11 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage'
|
'message' => 'myMessage'
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate('2', $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => '2',
|
'{{ value }}' => '2',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate('2', $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNonStrictWithMultipleChoices()
|
public function testNonStrictWithMultipleChoices()
|
||||||
@ -269,10 +253,9 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'strict' => false
|
'strict' => false
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(array('2', 3), $constraint);
|
$this->validator->validate(array('2', 3), $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStrictWithMultipleChoices()
|
public function testStrictWithMultipleChoices()
|
||||||
@ -284,12 +267,10 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'multipleMessage' => 'myMessage',
|
'multipleMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate(array(2, '3'), $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => '3',
|
'{{ value }}' => '3',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate(array(2, '3'), $constraint);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,63 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Validator\Tests\Constraints;
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
/**
|
use Symfony\Component\Validator\Tests\Fixtures\CustomArrayObject;
|
||||||
* This class is a hand written simplified version of PHP native `ArrayObject`
|
|
||||||
* class, to show that it behaves differently than the PHP native implementation.
|
|
||||||
*/
|
|
||||||
class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable
|
|
||||||
{
|
|
||||||
private $array;
|
|
||||||
|
|
||||||
public function __construct(array $array = null)
|
|
||||||
{
|
|
||||||
$this->array = $array ?: array();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetExists($offset)
|
|
||||||
{
|
|
||||||
return array_key_exists($offset, $this->array);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetGet($offset)
|
|
||||||
{
|
|
||||||
return $this->array[$offset];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetSet($offset, $value)
|
|
||||||
{
|
|
||||||
if (null === $offset) {
|
|
||||||
$this->array[] = $value;
|
|
||||||
} else {
|
|
||||||
$this->array[$offset] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function offsetUnset($offset)
|
|
||||||
{
|
|
||||||
unset($this->array[$offset]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIterator()
|
|
||||||
{
|
|
||||||
return new \ArrayIterator($this->array);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function count()
|
|
||||||
{
|
|
||||||
return count($this->array);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function serialize()
|
|
||||||
{
|
|
||||||
return serialize($this->array);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function unserialize($serialized)
|
|
||||||
{
|
|
||||||
$this->array = (array) unserialize((string) $serialized);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class CollectionValidatorCustomArrayObjectTest extends CollectionValidatorTest
|
class CollectionValidatorCustomArrayObjectTest extends CollectionValidatorTest
|
||||||
{
|
{
|
||||||
|
@ -17,51 +17,44 @@ use Symfony\Component\Validator\Constraints\NotNull;
|
|||||||
use Symfony\Component\Validator\Constraints\Optional;
|
use Symfony\Component\Validator\Constraints\Optional;
|
||||||
use Symfony\Component\Validator\Constraints\Range;
|
use Symfony\Component\Validator\Constraints\Range;
|
||||||
use Symfony\Component\Validator\Constraints\Required;
|
use Symfony\Component\Validator\Constraints\Required;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
abstract class CollectionValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new CollectionValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
|
||||||
->method('getGroup')
|
|
||||||
->will($this->returnValue('MyGroup'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
$this->context = null;
|
return new CollectionValidator();
|
||||||
$this->validator = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected function prepareTestData(array $contents);
|
abstract protected function prepareTestData(array $contents);
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolationAt');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new Collection(array('fields' => array(
|
$this->validator->validate(null, new Collection(array('fields' => array(
|
||||||
'foo' => new Range(array('min' => 4)),
|
'foo' => new Range(array('min' => 4)),
|
||||||
))));
|
))));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFieldsAsDefaultOption()
|
public function testFieldsAsDefaultOption()
|
||||||
{
|
{
|
||||||
|
$constraint = new Range(array('min' => 4));
|
||||||
|
|
||||||
$data = $this->prepareTestData(array('foo' => 'foobar'));
|
$data = $this->prepareTestData(array('foo' => 'foobar'));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
$this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint), 'MyGroup');
|
||||||
->method('addViolationAt');
|
|
||||||
|
|
||||||
$this->validator->validate($data, new Collection(array(
|
$this->validator->validate($data, new Collection(array(
|
||||||
'foo' => new Range(array('min' => 4)),
|
'foo' => $constraint,
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,25 +75,23 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'foo' => 3,
|
'foo' => 3,
|
||||||
'bar' => 5,
|
'bar' => 5,
|
||||||
);
|
);
|
||||||
$i = 1;
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
$this->context->expects($this->at($i++))
|
$this->expectValidateValueAt($i++, '['.$key.']', $value, array($constraint), 'MyGroup');
|
||||||
->method('validateValue')
|
|
||||||
->with($value, $constraint, '['.$key.']', 'MyGroup');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->prepareTestData($array);
|
$data = $this->prepareTestData($array);
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolationAt');
|
|
||||||
|
|
||||||
$this->validator->validate($data, new Collection(array(
|
$this->validator->validate($data, new Collection(array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'foo' => $constraint,
|
'foo' => $constraint,
|
||||||
'bar' => $constraint,
|
'bar' => $constraint,
|
||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWalkMultipleConstraints()
|
public function testWalkMultipleConstraints()
|
||||||
@ -114,48 +105,46 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'foo' => 3,
|
'foo' => 3,
|
||||||
'bar' => 5,
|
'bar' => 5,
|
||||||
);
|
);
|
||||||
$i = 1;
|
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
foreach ($constraints as $constraint) {
|
$this->expectValidateValueAt($i++, '['.$key.']', $value, $constraints, 'MyGroup');
|
||||||
$this->context->expects($this->at($i++))
|
|
||||||
->method('validateValue')
|
|
||||||
->with($value, $constraint, '['.$key.']', 'MyGroup');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->prepareTestData($array);
|
$data = $this->prepareTestData($array);
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolationAt');
|
|
||||||
|
|
||||||
$this->validator->validate($data, new Collection(array(
|
$this->validator->validate($data, new Collection(array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'foo' => $constraints,
|
'foo' => $constraints,
|
||||||
'bar' => $constraints,
|
'bar' => $constraints,
|
||||||
)
|
)
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExtraFieldsDisallowed()
|
public function testExtraFieldsDisallowed()
|
||||||
{
|
{
|
||||||
|
$constraint = new Range(array('min' => 4));
|
||||||
|
|
||||||
$data = $this->prepareTestData(array(
|
$data = $this->prepareTestData(array(
|
||||||
'foo' => 5,
|
'foo' => 5,
|
||||||
'baz' => 6,
|
'baz' => 6,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint), 'MyGroup');
|
||||||
->method('addViolationAt')
|
|
||||||
->with('[baz]', 'myMessage', array(
|
|
||||||
'{{ field }}' => 'baz'
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->validator->validate($data, new Collection(array(
|
$this->validator->validate($data, new Collection(array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'foo' => new Range(array('min' => 4)),
|
'foo' => $constraint,
|
||||||
),
|
),
|
||||||
'extraFieldsMessage' => 'myMessage',
|
'extraFieldsMessage' => 'myMessage',
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage', array(
|
||||||
|
'{{ field }}' => 'baz'
|
||||||
|
), 'property.path[baz]', 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
// bug fix
|
// bug fix
|
||||||
@ -165,16 +154,17 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'foo' => null,
|
'foo' => null,
|
||||||
));
|
));
|
||||||
|
|
||||||
$constraint = new Collection(array(
|
$constraint = new Range(array('min' => 4));
|
||||||
|
|
||||||
|
$this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint), 'MyGroup');
|
||||||
|
|
||||||
|
$this->validator->validate($data, new Collection(array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'foo' => new Range(array('min' => 4)),
|
'foo' => $constraint,
|
||||||
),
|
),
|
||||||
));
|
)));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
$this->assertNoViolation();
|
||||||
->method('addViolationAt');
|
|
||||||
|
|
||||||
$this->validator->validate($data, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExtraFieldsAllowed()
|
public function testExtraFieldsAllowed()
|
||||||
@ -184,54 +174,52 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'bar' => 6,
|
'bar' => 6,
|
||||||
));
|
));
|
||||||
|
|
||||||
$constraint = new Collection(array(
|
$constraint = new Range(array('min' => 4));
|
||||||
|
|
||||||
|
$this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint), 'MyGroup');
|
||||||
|
|
||||||
|
$this->validator->validate($data, new Collection(array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'foo' => new Range(array('min' => 4)),
|
'foo' => $constraint,
|
||||||
),
|
),
|
||||||
'allowExtraFields' => true,
|
'allowExtraFields' => true,
|
||||||
));
|
)));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
$this->assertNoViolation();
|
||||||
->method('addViolationAt');
|
|
||||||
|
|
||||||
$this->validator->validate($data, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMissingFieldsDisallowed()
|
public function testMissingFieldsDisallowed()
|
||||||
{
|
{
|
||||||
$data = $this->prepareTestData(array());
|
$data = $this->prepareTestData(array());
|
||||||
|
|
||||||
$constraint = new Collection(array(
|
$constraint = new Range(array('min' => 4));
|
||||||
|
|
||||||
|
$this->validator->validate($data, new Collection(array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'foo' => new Range(array('min' => 4)),
|
'foo' => $constraint,
|
||||||
),
|
),
|
||||||
'missingFieldsMessage' => 'myMessage',
|
'missingFieldsMessage' => 'myMessage',
|
||||||
));
|
)));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->assertViolation('myMessage', array(
|
||||||
->method('addViolationAt')
|
'{{ field }}' => 'foo'
|
||||||
->with('[foo]', 'myMessage', array(
|
), 'property.path[foo]', null);
|
||||||
'{{ field }}' => 'foo',
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->validator->validate($data, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMissingFieldsAllowed()
|
public function testMissingFieldsAllowed()
|
||||||
{
|
{
|
||||||
$data = $this->prepareTestData(array());
|
$data = $this->prepareTestData(array());
|
||||||
|
|
||||||
$constraint = new Collection(array(
|
$constraint = new Range(array('min' => 4));
|
||||||
|
|
||||||
|
$this->validator->validate($data, new Collection(array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'foo' => new Range(array('min' => 4)),
|
'foo' => $constraint,
|
||||||
),
|
),
|
||||||
'allowMissingFields' => true,
|
'allowMissingFields' => true,
|
||||||
));
|
)));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
$this->assertNoViolation();
|
||||||
->method('addViolationAt');
|
|
||||||
|
|
||||||
$this->validator->validate($data, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOptionalFieldPresent()
|
public function testOptionalFieldPresent()
|
||||||
@ -240,24 +228,22 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'foo' => null,
|
'foo' => null,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolationAt');
|
|
||||||
|
|
||||||
$this->validator->validate($data, new Collection(array(
|
$this->validator->validate($data, new Collection(array(
|
||||||
'foo' => new Optional(),
|
'foo' => new Optional(),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOptionalFieldNotPresent()
|
public function testOptionalFieldNotPresent()
|
||||||
{
|
{
|
||||||
$data = $this->prepareTestData(array());
|
$data = $this->prepareTestData(array());
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolationAt');
|
|
||||||
|
|
||||||
$this->validator->validate($data, new Collection(array(
|
$this->validator->validate($data, new Collection(array(
|
||||||
'foo' => new Optional(),
|
'foo' => new Optional(),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOptionalFieldSingleConstraint()
|
public function testOptionalFieldSingleConstraint()
|
||||||
@ -268,18 +254,15 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$constraint = new Range(array('min' => 4));
|
$constraint = new Range(array('min' => 4));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->expectValidateValueAt(0, '[foo]', $array['foo'], array($constraint), 'MyGroup');
|
||||||
->method('validateValue')
|
|
||||||
->with($array['foo'], $constraint, '[foo]', 'MyGroup');
|
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolationAt');
|
|
||||||
|
|
||||||
$data = $this->prepareTestData($array);
|
$data = $this->prepareTestData($array);
|
||||||
|
|
||||||
$this->validator->validate($data, new Collection(array(
|
$this->validator->validate($data, new Collection(array(
|
||||||
'foo' => new Optional($constraint),
|
'foo' => new Optional($constraint),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOptionalFieldMultipleConstraints()
|
public function testOptionalFieldMultipleConstraints()
|
||||||
@ -292,22 +275,16 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
new NotNull(),
|
new NotNull(),
|
||||||
new Range(array('min' => 4)),
|
new Range(array('min' => 4)),
|
||||||
);
|
);
|
||||||
$i = 1;
|
|
||||||
|
|
||||||
foreach ($constraints as $constraint) {
|
$this->expectValidateValueAt(0, '[foo]', $array['foo'], $constraints, 'MyGroup');
|
||||||
$this->context->expects($this->at($i++))
|
|
||||||
->method('validateValue')
|
|
||||||
->with($array['foo'], $constraint, '[foo]', 'MyGroup');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolationAt');
|
|
||||||
|
|
||||||
$data = $this->prepareTestData($array);
|
$data = $this->prepareTestData($array);
|
||||||
|
|
||||||
$this->validator->validate($data, new Collection(array(
|
$this->validator->validate($data, new Collection(array(
|
||||||
'foo' => new Optional($constraints),
|
'foo' => new Optional($constraints),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRequiredFieldPresent()
|
public function testRequiredFieldPresent()
|
||||||
@ -316,30 +293,28 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'foo' => null,
|
'foo' => null,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolationAt');
|
|
||||||
|
|
||||||
$this->validator->validate($data, new Collection(array(
|
$this->validator->validate($data, new Collection(array(
|
||||||
'foo' => new Required(),
|
'foo' => new Required(),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRequiredFieldNotPresent()
|
public function testRequiredFieldNotPresent()
|
||||||
{
|
{
|
||||||
$data = $this->prepareTestData(array());
|
$data = $this->prepareTestData(array());
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
|
||||||
->method('addViolationAt')
|
|
||||||
->with('[foo]', 'myMessage', array(
|
|
||||||
'{{ field }}' => 'foo',
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->validator->validate($data, new Collection(array(
|
$this->validator->validate($data, new Collection(array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'foo' => new Required(),
|
'foo' => new Required(),
|
||||||
),
|
),
|
||||||
'missingFieldsMessage' => 'myMessage',
|
'missingFieldsMessage' => 'myMessage',
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage', array(
|
||||||
|
'{{ field }}' => 'foo'
|
||||||
|
), 'property.path[foo]', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRequiredFieldSingleConstraint()
|
public function testRequiredFieldSingleConstraint()
|
||||||
@ -350,18 +325,15 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$constraint = new Range(array('min' => 4));
|
$constraint = new Range(array('min' => 4));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->expectValidateValueAt(0, '[foo]', $array['foo'], array($constraint), 'MyGroup');
|
||||||
->method('validateValue')
|
|
||||||
->with($array['foo'], $constraint, '[foo]', 'MyGroup');
|
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolationAt');
|
|
||||||
|
|
||||||
$data = $this->prepareTestData($array);
|
$data = $this->prepareTestData($array);
|
||||||
|
|
||||||
$this->validator->validate($data, new Collection(array(
|
$this->validator->validate($data, new Collection(array(
|
||||||
'foo' => new Required($constraint),
|
'foo' => new Required($constraint),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRequiredFieldMultipleConstraints()
|
public function testRequiredFieldMultipleConstraints()
|
||||||
@ -374,22 +346,16 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
new NotNull(),
|
new NotNull(),
|
||||||
new Range(array('min' => 4)),
|
new Range(array('min' => 4)),
|
||||||
);
|
);
|
||||||
$i = 1;
|
|
||||||
|
|
||||||
foreach ($constraints as $constraint) {
|
$this->expectValidateValueAt(0, '[foo]', $array['foo'], $constraints, 'MyGroup');
|
||||||
$this->context->expects($this->at($i++))
|
|
||||||
->method('validateValue')
|
|
||||||
->with($array['foo'], $constraint, '[foo]', 'MyGroup');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolationAt');
|
|
||||||
|
|
||||||
$data = $this->prepareTestData($array);
|
$data = $this->prepareTestData($array);
|
||||||
|
|
||||||
$this->validator->validate($array, new Collection(array(
|
$this->validator->validate($data, new Collection(array(
|
||||||
'foo' => new Required($constraints),
|
'foo' => new Required($constraints),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testObjectShouldBeLeftUnchanged()
|
public function testObjectShouldBeLeftUnchanged()
|
||||||
@ -398,9 +364,13 @@ abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'foo' => 3
|
'foo' => 3
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$constraint = new Range(array('min' => 2));
|
||||||
|
|
||||||
|
$this->expectValidateValueAt(0, '[foo]', $value['foo'], array($constraint), 'MyGroup');
|
||||||
|
|
||||||
$this->validator->validate($value, new Collection(array(
|
$this->validator->validate($value, new Collection(array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'foo' => new Range(array('min' => 2)),
|
'foo' => $constraint,
|
||||||
)
|
)
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
@ -11,20 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Validator\Tests\Constraints;
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
class CountValidatorCountableTest_Countable implements \Countable
|
use Symfony\Component\Validator\Tests\Fixtures\Countable;
|
||||||
{
|
|
||||||
private $content;
|
|
||||||
|
|
||||||
public function __construct(array $content)
|
|
||||||
{
|
|
||||||
$this->content = $content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function count()
|
|
||||||
{
|
|
||||||
return count($this->content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
@ -33,6 +20,6 @@ class CountValidatorCountableTest extends CountValidatorTest
|
|||||||
{
|
{
|
||||||
protected function createCollection(array $content)
|
protected function createCollection(array $content)
|
||||||
{
|
{
|
||||||
return new CountValidatorCountableTest_Countable($content);
|
return new Countable($content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,36 +13,30 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Count;
|
use Symfony\Component\Validator\Constraints\Count;
|
||||||
use Symfony\Component\Validator\Constraints\CountValidator;
|
use Symfony\Component\Validator\Constraints\CountValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
abstract class CountValidatorTest extends \PHPUnit_Framework_TestCase
|
abstract class CountValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new CountValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
$this->context = null;
|
return new CountValidator();
|
||||||
$this->validator = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected function createCollection(array $content);
|
abstract protected function createCollection(array $content);
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new Count(6));
|
$this->validator->validate(null, new Count(6));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,11 +87,10 @@ abstract class CountValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidValuesMax($value)
|
public function testValidValuesMax($value)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$constraint = new Count(array('max' => 3));
|
$constraint = new Count(array('max' => 3));
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,11 +98,10 @@ abstract class CountValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidValuesMin($value)
|
public function testValidValuesMin($value)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$constraint = new Count(array('min' => 5));
|
$constraint = new Count(array('min' => 5));
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,11 +109,10 @@ abstract class CountValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidValuesExact($value)
|
public function testValidValuesExact($value)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$constraint = new Count(4);
|
$constraint = new Count(4);
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -134,14 +125,12 @@ abstract class CountValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'maxMessage' => 'myMessage'
|
'maxMessage' => 'myMessage'
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($value, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', $this->identicalTo(array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ count }}' => count($value),
|
'{{ count }}' => count($value),
|
||||||
'{{ limit }}' => 4,
|
'{{ limit }}' => 4,
|
||||||
)), $value, 4);
|
), 'property.path', $value, 4);
|
||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -154,14 +143,12 @@ abstract class CountValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'minMessage' => 'myMessage'
|
'minMessage' => 'myMessage'
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($value, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', $this->identicalTo(array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ count }}' => count($value),
|
'{{ count }}' => count($value),
|
||||||
'{{ limit }}' => 4,
|
'{{ limit }}' => 4,
|
||||||
)), $value, 4);
|
), 'property.path', $value, 4);
|
||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,14 +162,12 @@ abstract class CountValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'exactMessage' => 'myMessage'
|
'exactMessage' => 'myMessage'
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($value, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', $this->identicalTo(array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ count }}' => count($value),
|
'{{ count }}' => count($value),
|
||||||
'{{ limit }}' => 4,
|
'{{ limit }}' => 4,
|
||||||
)), $value, 4);
|
), 'property.path', $value, 4);
|
||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultOption()
|
public function testDefaultOption()
|
||||||
|
@ -14,41 +14,39 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
use Symfony\Component\Intl\Util\IntlTestHelper;
|
use Symfony\Component\Intl\Util\IntlTestHelper;
|
||||||
use Symfony\Component\Validator\Constraints\Country;
|
use Symfony\Component\Validator\Constraints\Country;
|
||||||
use Symfony\Component\Validator\Constraints\CountryValidator;
|
use Symfony\Component\Validator\Constraints\CountryValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class CountryValidatorTest extends \PHPUnit_Framework_TestCase
|
class CountryValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
IntlTestHelper::requireFullIntl($this);
|
IntlTestHelper::requireFullIntl($this);
|
||||||
|
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
parent::setUp();
|
||||||
$this->validator = new CountryValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function getApiVersion()
|
||||||
{
|
{
|
||||||
$this->context = null;
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = null;
|
}
|
||||||
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new CountryValidator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new Country());
|
$this->validator->validate(null, new Country());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringIsValid()
|
public function testEmptyStringIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', new Country());
|
$this->validator->validate('', new Country());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,10 +62,9 @@ class CountryValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidCountries($country)
|
public function testValidCountries($country)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($country, new Country());
|
$this->validator->validate($country, new Country());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidCountries()
|
public function getValidCountries()
|
||||||
@ -88,13 +85,11 @@ class CountryValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage'
|
'message' => 'myMessage'
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($country, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $country,
|
'{{ value }}' => $country,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($country, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidCountries()
|
public function getInvalidCountries()
|
||||||
@ -113,9 +108,9 @@ class CountryValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
\Locale::setDefault('en_GB');
|
\Locale::setDefault('en_GB');
|
||||||
|
|
||||||
$existingCountry = 'GB';
|
$existingCountry = 'GB';
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($existingCountry, new Country());
|
$this->validator->validate($existingCountry, new Country());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,41 +14,39 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
use Symfony\Component\Intl\Util\IntlTestHelper;
|
use Symfony\Component\Intl\Util\IntlTestHelper;
|
||||||
use Symfony\Component\Validator\Constraints\Currency;
|
use Symfony\Component\Validator\Constraints\Currency;
|
||||||
use Symfony\Component\Validator\Constraints\CurrencyValidator;
|
use Symfony\Component\Validator\Constraints\CurrencyValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class CurrencyValidatorTest extends \PHPUnit_Framework_TestCase
|
class CurrencyValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
IntlTestHelper::requireFullIntl($this);
|
IntlTestHelper::requireFullIntl($this);
|
||||||
|
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
parent::setUp();
|
||||||
$this->validator = new CurrencyValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function getApiVersion()
|
||||||
{
|
{
|
||||||
$this->context = null;
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = null;
|
}
|
||||||
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new CurrencyValidator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new Currency());
|
$this->validator->validate(null, new Currency());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringIsValid()
|
public function testEmptyStringIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', new Currency());
|
$this->validator->validate('', new Currency());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,10 +62,9 @@ class CurrencyValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidCurrencies($currency)
|
public function testValidCurrencies($currency)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($currency, new Currency());
|
$this->validator->validate($currency, new Currency());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,10 +73,10 @@ class CurrencyValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testValidCurrenciesWithCountrySpecificLocale($currency)
|
public function testValidCurrenciesWithCountrySpecificLocale($currency)
|
||||||
{
|
{
|
||||||
\Locale::setDefault('en_GB');
|
\Locale::setDefault('en_GB');
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($currency, new Currency());
|
$this->validator->validate($currency, new Currency());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidCurrencies()
|
public function getValidCurrencies()
|
||||||
@ -102,13 +99,11 @@ class CurrencyValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage'
|
'message' => 'myMessage'
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($currency, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $currency,
|
'{{ value }}' => $currency,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($currency, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidCurrencies()
|
public function getInvalidCurrencies()
|
||||||
|
@ -13,47 +13,39 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\DateTime;
|
use Symfony\Component\Validator\Constraints\DateTime;
|
||||||
use Symfony\Component\Validator\Constraints\DateTimeValidator;
|
use Symfony\Component\Validator\Constraints\DateTimeValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class DateTimeValidatorTest extends \PHPUnit_Framework_TestCase
|
class DateTimeValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new DateTimeValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
$this->context = null;
|
return new DateTimeValidator();
|
||||||
$this->validator = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new DateTime());
|
$this->validator->validate(null, new DateTime());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringIsValid()
|
public function testEmptyStringIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', new DateTime());
|
$this->validator->validate('', new DateTime());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDateTimeClassIsValid()
|
public function testDateTimeClassIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(new \DateTime(), new DateTime());
|
$this->validator->validate(new \DateTime(), new DateTime());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,10 +61,9 @@ class DateTimeValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidDateTimes($dateTime)
|
public function testValidDateTimes($dateTime)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($dateTime, new DateTime());
|
$this->validator->validate($dateTime, new DateTime());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidDateTimes()
|
public function getValidDateTimes()
|
||||||
@ -93,13 +84,11 @@ class DateTimeValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage'
|
'message' => 'myMessage'
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($dateTime, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $dateTime,
|
'{{ value }}' => $dateTime,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($dateTime, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidDateTimes()
|
public function getInvalidDateTimes()
|
||||||
|
@ -13,47 +13,39 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Date;
|
use Symfony\Component\Validator\Constraints\Date;
|
||||||
use Symfony\Component\Validator\Constraints\DateValidator;
|
use Symfony\Component\Validator\Constraints\DateValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class DateValidatorTest extends \PHPUnit_Framework_TestCase
|
class DateValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new DateValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
$this->context = null;
|
return new DateValidator();
|
||||||
$this->validator = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new Date());
|
$this->validator->validate(null, new Date());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringIsValid()
|
public function testEmptyStringIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', new Date());
|
$this->validator->validate('', new Date());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDateTimeClassIsValid()
|
public function testDateTimeClassIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(new \DateTime(), new Date());
|
$this->validator->validate(new \DateTime(), new Date());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,10 +61,9 @@ class DateValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidDates($date)
|
public function testValidDates($date)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($date, new Date());
|
$this->validator->validate($date, new Date());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidDates()
|
public function getValidDates()
|
||||||
@ -93,13 +84,11 @@ class DateValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage'
|
'message' => 'myMessage'
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($date, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $date,
|
'{{ value }}' => $date,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($date, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidDates()
|
public function getInvalidDates()
|
||||||
|
@ -13,39 +13,32 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Email;
|
use Symfony\Component\Validator\Constraints\Email;
|
||||||
use Symfony\Component\Validator\Constraints\EmailValidator;
|
use Symfony\Component\Validator\Constraints\EmailValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
class EmailValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new EmailValidator(false);
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
$this->context = null;
|
return new EmailValidator(false);
|
||||||
$this->validator = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new Email());
|
$this->validator->validate(null, new Email());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringIsValid()
|
public function testEmptyStringIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', new Email());
|
$this->validator->validate('', new Email());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,10 +54,9 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidEmails($email)
|
public function testValidEmails($email)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($email, new Email());
|
$this->validator->validate($email, new Email());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidEmails()
|
public function getValidEmails()
|
||||||
@ -85,13 +77,11 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage'
|
'message' => 'myMessage'
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($email, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $email,
|
'{{ value }}' => $email,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($email, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidEmails()
|
public function getInvalidEmails()
|
||||||
@ -105,9 +95,10 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testStrict()
|
public function testStrict()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
$constraint = new Email(array('strict' => true));
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('example@localhost', new Email(array('strict' => true)));
|
$this->validator->validate('example@localhost', $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,18 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\EqualTo;
|
use Symfony\Component\Validator\Constraints\EqualTo;
|
||||||
use Symfony\Component\Validator\Constraints\EqualToValidator;
|
use Symfony\Component\Validator\Constraints\EqualToValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||||
*/
|
*/
|
||||||
class EqualToValidatorTest extends AbstractComparisonValidatorTestCase
|
class EqualToValidatorTest extends AbstractComparisonValidatorTestCase
|
||||||
{
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5;
|
||||||
|
}
|
||||||
|
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
return new EqualToValidator();
|
return new EqualToValidator();
|
||||||
|
@ -14,184 +14,139 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
use Symfony\Component\PropertyAccess\PropertyAccess;
|
use Symfony\Component\PropertyAccess\PropertyAccess;
|
||||||
use Symfony\Component\Validator\Constraints\Expression;
|
use Symfony\Component\Validator\Constraints\Expression;
|
||||||
use Symfony\Component\Validator\Constraints\ExpressionValidator;
|
use Symfony\Component\Validator\Constraints\ExpressionValidator;
|
||||||
|
use Symfony\Component\Validator\Tests\Fixtures\Entity;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class ExpressionValidatorTest extends \PHPUnit_Framework_TestCase
|
class ExpressionValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new ExpressionValidator(PropertyAccess::createPropertyAccessor());
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
|
||||||
->method('getClassName')
|
|
||||||
->will($this->returnValue(__CLASS__));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
$this->context = null;
|
return new ExpressionValidator(PropertyAccess::createPropertyAccessor());
|
||||||
$this->validator = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new Expression('value == 1'));
|
$this->validator->validate(null, new Expression('value == 1'));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringIsValid()
|
public function testEmptyStringIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', new Expression('value == 1'));
|
$this->validator->validate('', new Expression('value == 1'));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSucceedingExpressionAtObjectLevel()
|
public function testSucceedingExpressionAtObjectLevel()
|
||||||
{
|
{
|
||||||
$constraint = new Expression('this.property == 1');
|
$constraint = new Expression('this.data == 1');
|
||||||
|
|
||||||
$object = (object) array('property' => '1');
|
$object = new Entity();
|
||||||
|
$object->data = '1';
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
$this->setObject($object);
|
||||||
->method('getPropertyName')
|
|
||||||
->will($this->returnValue(null));
|
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
$this->validator->validate($object, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFailingExpressionAtObjectLevel()
|
public function testFailingExpressionAtObjectLevel()
|
||||||
{
|
{
|
||||||
$constraint = new Expression(array(
|
$constraint = new Expression(array(
|
||||||
'expression' => 'this.property == 1',
|
'expression' => 'this.data == 1',
|
||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$object = (object) array('property' => '2');
|
$object = new Entity();
|
||||||
|
$object->data = '2';
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
$this->setObject($object);
|
||||||
->method('getPropertyName')
|
|
||||||
->will($this->returnValue(null));
|
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage');
|
|
||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
$this->validator->validate($object, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSucceedingExpressionAtPropertyLevel()
|
public function testSucceedingExpressionAtPropertyLevel()
|
||||||
{
|
{
|
||||||
$constraint = new Expression('value == this.expected');
|
$constraint = new Expression('value == this.data');
|
||||||
|
|
||||||
$object = (object) array('expected' => '1');
|
$object = new Entity();
|
||||||
|
$object->data = '1';
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
$this->setRoot($object);
|
||||||
->method('getPropertyName')
|
$this->setPropertyPath('data');
|
||||||
->will($this->returnValue('property'));
|
$this->setProperty($object, 'data');
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
|
||||||
->method('getPropertyPath')
|
|
||||||
->will($this->returnValue('property'));
|
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
|
||||||
->method('getRoot')
|
|
||||||
->will($this->returnValue($object));
|
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('1', $constraint);
|
$this->validator->validate('1', $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFailingExpressionAtPropertyLevel()
|
public function testFailingExpressionAtPropertyLevel()
|
||||||
{
|
{
|
||||||
$constraint = new Expression(array(
|
$constraint = new Expression(array(
|
||||||
'expression' => 'value == this.expected',
|
'expression' => 'value == this.data',
|
||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$object = (object) array('expected' => '1');
|
$object = new Entity();
|
||||||
|
$object->data = '1';
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
$this->setRoot($object);
|
||||||
->method('getPropertyName')
|
$this->setPropertyPath('data');
|
||||||
->will($this->returnValue('property'));
|
$this->setProperty($object, 'data');
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
|
||||||
->method('getPropertyPath')
|
|
||||||
->will($this->returnValue('property'));
|
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
|
||||||
->method('getRoot')
|
|
||||||
->will($this->returnValue($object));
|
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage');
|
|
||||||
|
|
||||||
$this->validator->validate('2', $constraint);
|
$this->validator->validate('2', $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage', array(), 'data');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSucceedingExpressionAtNestedPropertyLevel()
|
public function testSucceedingExpressionAtNestedPropertyLevel()
|
||||||
{
|
{
|
||||||
$constraint = new Expression('value == this.expected');
|
$constraint = new Expression('value == this.data');
|
||||||
|
|
||||||
$object = (object) array('expected' => '1');
|
$object = new Entity();
|
||||||
$root = (object) array('nested' => $object);
|
$object->data = '1';
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
$root = new Entity();
|
||||||
->method('getPropertyName')
|
$root->reference = $object;
|
||||||
->will($this->returnValue('property'));
|
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
$this->setRoot($root);
|
||||||
->method('getPropertyPath')
|
$this->setPropertyPath('reference.data');
|
||||||
->will($this->returnValue('nested.property'));
|
$this->setProperty($object, 'data');
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
|
||||||
->method('getRoot')
|
|
||||||
->will($this->returnValue($root));
|
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('1', $constraint);
|
$this->validator->validate('1', $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFailingExpressionAtNestedPropertyLevel()
|
public function testFailingExpressionAtNestedPropertyLevel()
|
||||||
{
|
{
|
||||||
$constraint = new Expression(array(
|
$constraint = new Expression(array(
|
||||||
'expression' => 'value == this.expected',
|
'expression' => 'value == this.data',
|
||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$object = (object) array('expected' => '1');
|
$object = new Entity();
|
||||||
$root = (object) array('nested' => $object);
|
$object->data = '1';
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
$root = new Entity();
|
||||||
->method('getPropertyName')
|
$root->reference = $object;
|
||||||
->will($this->returnValue('property'));
|
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
$this->setRoot($root);
|
||||||
->method('getPropertyPath')
|
$this->setPropertyPath('reference.data');
|
||||||
->will($this->returnValue('nested.property'));
|
$this->setProperty($object, 'data');
|
||||||
|
|
||||||
$this->context->expects($this->any())
|
|
||||||
->method('getRoot')
|
|
||||||
->will($this->returnValue($root));
|
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage');
|
|
||||||
|
|
||||||
$this->validator->validate('2', $constraint);
|
$this->validator->validate('2', $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage', array(), 'reference.data');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,39 +13,32 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\False;
|
use Symfony\Component\Validator\Constraints\False;
|
||||||
use Symfony\Component\Validator\Constraints\FalseValidator;
|
use Symfony\Component\Validator\Constraints\FalseValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class FalseValidatorTest extends \PHPUnit_Framework_TestCase
|
class FalseValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new FalseValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
$this->context = null;
|
return new FalseValidator();
|
||||||
$this->validator = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new False());
|
$this->validator->validate(null, new False());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFalseIsValid()
|
public function testFalseIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(false, new False());
|
$this->validator->validate(false, new False());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTrueIsInvalid()
|
public function testTrueIsInvalid()
|
||||||
@ -54,10 +47,8 @@ class FalseValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage'
|
'message' => 'myMessage'
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array());
|
|
||||||
|
|
||||||
$this->validator->validate(true, $constraint);
|
$this->validator->validate(true, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,10 @@ class FileValidatorPathTest extends FileValidatorTest
|
|||||||
'notFoundMessage' => 'myMessage',
|
'notFoundMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate('foobar', $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ file }}' => 'foobar',
|
'{{ file }}' => 'foobar',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate('foobar', $constraint);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,25 +14,36 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
use Symfony\Component\Validator\Constraints\File;
|
use Symfony\Component\Validator\Constraints\File;
|
||||||
use Symfony\Component\Validator\Constraints\FileValidator;
|
use Symfony\Component\Validator\Constraints\FileValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
abstract class FileValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
|
||||||
protected $validator;
|
|
||||||
protected $path;
|
protected $path;
|
||||||
|
|
||||||
protected $file;
|
protected $file;
|
||||||
|
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new FileValidator();
|
||||||
|
}
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
parent::setUp();
|
||||||
$this->validator = new FileValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
$this->path = sys_get_temp_dir().DIRECTORY_SEPARATOR.'FileValidatorTest';
|
$this->path = sys_get_temp_dir().DIRECTORY_SEPARATOR.'FileValidatorTest';
|
||||||
$this->file = fopen($this->path, 'w');
|
$this->file = fopen($this->path, 'w');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
|
parent::tearDown();
|
||||||
|
|
||||||
if (is_resource($this->file)) {
|
if (is_resource($this->file)) {
|
||||||
fclose($this->file);
|
fclose($this->file);
|
||||||
}
|
}
|
||||||
@ -41,26 +52,22 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
unlink($this->path);
|
unlink($this->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->context = null;
|
|
||||||
$this->validator = null;
|
|
||||||
$this->path = null;
|
$this->path = null;
|
||||||
$this->file = null;
|
$this->file = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new File());
|
$this->validator->validate(null, new File());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringIsValid()
|
public function testEmptyStringIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', new File());
|
$this->validator->validate('', new File());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,19 +80,17 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testValidFile()
|
public function testValidFile()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($this->path, new File());
|
$this->validator->validate($this->path, new File());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidUploadedfile()
|
public function testValidUploadedfile()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$file = new UploadedFile($this->path, 'originalName', null, null, null, true);
|
$file = new UploadedFile($this->path, 'originalName', null, null, null, true);
|
||||||
$this->validator->validate($file, new File());
|
$this->validator->validate($file, new File());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideMaxSizeExceededTests()
|
public function provideMaxSizeExceededTests()
|
||||||
@ -137,16 +142,14 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'maxSizeMessage' => 'myMessage',
|
'maxSizeMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($this->getFile($this->path), $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ limit }}' => $limitAsString,
|
'{{ limit }}' => $limitAsString,
|
||||||
'{{ size }}' => $sizeAsString,
|
'{{ size }}' => $sizeAsString,
|
||||||
'{{ suffix }}' => $suffix,
|
'{{ suffix }}' => $suffix,
|
||||||
'{{ file }}' => $this->path,
|
'{{ file }}' => $this->path,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($this->getFile($this->path), $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideMaxSizeNotExceededTests()
|
public function provideMaxSizeNotExceededTests()
|
||||||
@ -177,10 +180,9 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'maxSizeMessage' => 'myMessage',
|
'maxSizeMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($this->getFile($this->path), $constraint);
|
$this->validator->validate($this->getFile($this->path), $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -213,14 +215,13 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
->will($this->returnValue('image/jpg'))
|
->will($this->returnValue('image/jpg'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$constraint = new File(array(
|
$constraint = new File(array(
|
||||||
'mimeTypes' => array('image/png', 'image/jpg'),
|
'mimeTypes' => array('image/png', 'image/jpg'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($file, $constraint);
|
$this->validator->validate($file, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidWildcardMimeType()
|
public function testValidWildcardMimeType()
|
||||||
@ -241,14 +242,13 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
->will($this->returnValue('image/jpg'))
|
->will($this->returnValue('image/jpg'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$constraint = new File(array(
|
$constraint = new File(array(
|
||||||
'mimeTypes' => array('image/*'),
|
'mimeTypes' => array('image/*'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($file, $constraint);
|
$this->validator->validate($file, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidMimeType()
|
public function testInvalidMimeType()
|
||||||
@ -274,15 +274,13 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'mimeTypesMessage' => 'myMessage',
|
'mimeTypesMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($file, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ type }}' => '"application/pdf"',
|
'{{ type }}' => '"application/pdf"',
|
||||||
'{{ types }}' => '"image/png", "image/jpg"',
|
'{{ types }}' => '"image/png", "image/jpg"',
|
||||||
'{{ file }}' => $this->path,
|
'{{ file }}' => $this->path,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($file, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidWildcardMimeType()
|
public function testInvalidWildcardMimeType()
|
||||||
@ -308,15 +306,13 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'mimeTypesMessage' => 'myMessage',
|
'mimeTypesMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($file, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ type }}' => '"application/pdf"',
|
'{{ type }}' => '"application/pdf"',
|
||||||
'{{ types }}' => '"image/*", "image/jpg"',
|
'{{ types }}' => '"image/*", "image/jpg"',
|
||||||
'{{ file }}' => $this->path,
|
'{{ file }}' => $this->path,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($file, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -331,12 +327,10 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'maxSize' => $maxSize
|
'maxSize' => $maxSize
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', $params);
|
|
||||||
|
|
||||||
$this->validator->validate($file, $constraint);
|
$this->validator->validate($file, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage', $params);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uploadedFileErrorProvider()
|
public function uploadedFileErrorProvider()
|
||||||
|
@ -13,12 +13,18 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
|
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
|
||||||
use Symfony\Component\Validator\Constraints\GreaterThanOrEqualValidator;
|
use Symfony\Component\Validator\Constraints\GreaterThanOrEqualValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||||
*/
|
*/
|
||||||
class GreaterThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase
|
class GreaterThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase
|
||||||
{
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5;
|
||||||
|
}
|
||||||
|
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
return new GreaterThanOrEqualValidator();
|
return new GreaterThanOrEqualValidator();
|
||||||
|
@ -13,12 +13,18 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||||
use Symfony\Component\Validator\Constraints\GreaterThanValidator;
|
use Symfony\Component\Validator\Constraints\GreaterThanValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||||
*/
|
*/
|
||||||
class GreaterThanValidatorTest extends AbstractComparisonValidatorTestCase
|
class GreaterThanValidatorTest extends AbstractComparisonValidatorTestCase
|
||||||
{
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5;
|
||||||
|
}
|
||||||
|
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
return new GreaterThanValidator();
|
return new GreaterThanValidator();
|
||||||
|
@ -13,31 +13,32 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Iban;
|
use Symfony\Component\Validator\Constraints\Iban;
|
||||||
use Symfony\Component\Validator\Constraints\IbanValidator;
|
use Symfony\Component\Validator\Constraints\IbanValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class IbanValidatorTest extends \PHPUnit_Framework_TestCase
|
class IbanValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new IbanValidator();
|
}
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new IbanValidator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new Iban());
|
$this->validator->validate(null, new Iban());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringIsValid()
|
public function testEmptyStringIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', new Iban());
|
$this->validator->validate('', new Iban());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,9 +46,9 @@ class IbanValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidIbans($iban)
|
public function testValidIbans($iban)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($iban, new Iban());
|
$this->validator->validate($iban, new Iban());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidIbans()
|
public function getValidIbans()
|
||||||
@ -160,13 +161,11 @@ class IbanValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage'
|
'message' => 'myMessage'
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($iban, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $iban,
|
'{{ value }}' => $iban,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($iban, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidIbans()
|
public function getInvalidIbans()
|
||||||
|
@ -13,12 +13,18 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\IdenticalTo;
|
use Symfony\Component\Validator\Constraints\IdenticalTo;
|
||||||
use Symfony\Component\Validator\Constraints\IdenticalToValidator;
|
use Symfony\Component\Validator\Constraints\IdenticalToValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||||
*/
|
*/
|
||||||
class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase
|
class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase
|
||||||
{
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5;
|
||||||
|
}
|
||||||
|
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
return new IdenticalToValidator();
|
return new IdenticalToValidator();
|
||||||
|
@ -13,8 +13,9 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Image;
|
use Symfony\Component\Validator\Constraints\Image;
|
||||||
use Symfony\Component\Validator\Constraints\ImageValidator;
|
use Symfony\Component\Validator\Constraints\ImageValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
class ImageValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected $context;
|
||||||
protected $validator;
|
protected $validator;
|
||||||
@ -23,11 +24,20 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
protected $imageLandscape;
|
protected $imageLandscape;
|
||||||
protected $imagePortrait;
|
protected $imagePortrait;
|
||||||
|
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new ImageValidator();
|
||||||
|
}
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
parent::setUp();
|
||||||
$this->validator = new ImageValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
$this->image = __DIR__.'/Fixtures/test.gif';
|
$this->image = __DIR__.'/Fixtures/test.gif';
|
||||||
$this->imageLandscape = __DIR__.'/Fixtures/test_landscape.gif';
|
$this->imageLandscape = __DIR__.'/Fixtures/test_landscape.gif';
|
||||||
$this->imagePortrait = __DIR__.'/Fixtures/test_portrait.gif';
|
$this->imagePortrait = __DIR__.'/Fixtures/test_portrait.gif';
|
||||||
@ -35,33 +45,27 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new Image());
|
$this->validator->validate(null, new Image());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringIsValid()
|
public function testEmptyStringIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', new Image());
|
$this->validator->validate('', new Image());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidImage()
|
public function testValidImage()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($this->image, new Image());
|
$this->validator->validate($this->image, new Image());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidSize()
|
public function testValidSize()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$constraint = new Image(array(
|
$constraint = new Image(array(
|
||||||
'minWidth' => 1,
|
'minWidth' => 1,
|
||||||
'maxWidth' => 2,
|
'maxWidth' => 2,
|
||||||
@ -70,6 +74,8 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($this->image, $constraint);
|
$this->validator->validate($this->image, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWidthTooSmall()
|
public function testWidthTooSmall()
|
||||||
@ -79,14 +85,12 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'minWidthMessage' => 'myMessage',
|
'minWidthMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($this->image, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ width }}' => '2',
|
'{{ width }}' => '2',
|
||||||
'{{ min_width }}' => '3',
|
'{{ min_width }}' => '3',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($this->image, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWidthTooBig()
|
public function testWidthTooBig()
|
||||||
@ -96,14 +100,12 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'maxWidthMessage' => 'myMessage',
|
'maxWidthMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($this->image, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ width }}' => '2',
|
'{{ width }}' => '2',
|
||||||
'{{ max_width }}' => '1',
|
'{{ max_width }}' => '1',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($this->image, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHeightTooSmall()
|
public function testHeightTooSmall()
|
||||||
@ -113,14 +115,12 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'minHeightMessage' => 'myMessage',
|
'minHeightMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($this->image, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ height }}' => '2',
|
'{{ height }}' => '2',
|
||||||
'{{ min_height }}' => '3',
|
'{{ min_height }}' => '3',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($this->image, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHeightTooBig()
|
public function testHeightTooBig()
|
||||||
@ -130,14 +130,12 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'maxHeightMessage' => 'myMessage',
|
'maxHeightMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($this->image, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ height }}' => '2',
|
'{{ height }}' => '2',
|
||||||
'{{ max_height }}' => '1',
|
'{{ max_height }}' => '1',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($this->image, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -195,14 +193,12 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'minRatioMessage' => 'myMessage',
|
'minRatioMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($this->image, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ ratio }}' => 1,
|
'{{ ratio }}' => 1,
|
||||||
'{{ min_ratio }}' => 2,
|
'{{ min_ratio }}' => 2,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($this->image, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRatioTooBig()
|
public function testRatioTooBig()
|
||||||
@ -212,14 +208,12 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'maxRatioMessage' => 'myMessage',
|
'maxRatioMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($this->image, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ ratio }}' => 1,
|
'{{ ratio }}' => 1,
|
||||||
'{{ max_ratio }}' => 0.5,
|
'{{ max_ratio }}' => 0.5,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($this->image, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -253,14 +247,12 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'allowSquareMessage' => 'myMessage',
|
'allowSquareMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($this->image, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ width }}' => 2,
|
'{{ width }}' => 2,
|
||||||
'{{ height }}' => 2,
|
'{{ height }}' => 2,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($this->image, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLandscapeNotAllowed()
|
public function testLandscapeNotAllowed()
|
||||||
@ -270,14 +262,12 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'allowLandscapeMessage' => 'myMessage',
|
'allowLandscapeMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($this->imageLandscape, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ width }}' => 2,
|
'{{ width }}' => 2,
|
||||||
'{{ height }}' => 1,
|
'{{ height }}' => 1,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($this->imageLandscape, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPortraitNotAllowed()
|
public function testPortraitNotAllowed()
|
||||||
@ -287,13 +277,11 @@ class ImageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'allowPortraitMessage' => 'myMessage',
|
'allowPortraitMessage' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($this->imagePortrait, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ width }}' => 1,
|
'{{ width }}' => 1,
|
||||||
'{{ height }}' => 2,
|
'{{ height }}' => 2,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($this->imagePortrait, $constraint);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,39 +13,32 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Ip;
|
use Symfony\Component\Validator\Constraints\Ip;
|
||||||
use Symfony\Component\Validator\Constraints\IpValidator;
|
use Symfony\Component\Validator\Constraints\IpValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
class IpValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new IpValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
$this->context = null;
|
return new IpValidator();
|
||||||
$this->validator = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new Ip());
|
$this->validator->validate(null, new Ip());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringIsValid()
|
public function testEmptyStringIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', new Ip());
|
$this->validator->validate('', new Ip());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +54,7 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidValidatorVersion()
|
public function testInvalidValidatorVersion()
|
||||||
{
|
{
|
||||||
$ip = new Ip(array(
|
new Ip(array(
|
||||||
'version' => 666,
|
'version' => 666,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -71,12 +64,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidIpsV4($ip)
|
public function testValidIpsV4($ip)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($ip, new Ip(array(
|
$this->validator->validate($ip, new Ip(array(
|
||||||
'version' => Ip::V4,
|
'version' => Ip::V4,
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidIpsV4()
|
public function getValidIpsV4()
|
||||||
@ -98,12 +90,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidIpsV6($ip)
|
public function testValidIpsV6($ip)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($ip, new Ip(array(
|
$this->validator->validate($ip, new Ip(array(
|
||||||
'version' => Ip::V6,
|
'version' => Ip::V6,
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidIpsV6()
|
public function getValidIpsV6()
|
||||||
@ -136,12 +127,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidIpsAll($ip)
|
public function testValidIpsAll($ip)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($ip, new Ip(array(
|
$this->validator->validate($ip, new Ip(array(
|
||||||
'version' => Ip::ALL,
|
'version' => Ip::ALL,
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidIpsAll()
|
public function getValidIpsAll()
|
||||||
@ -159,13 +149,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($ip, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $ip,
|
'{{ value }}' => $ip,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidIpsV4()
|
public function getInvalidIpsV4()
|
||||||
@ -193,13 +181,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($ip, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $ip,
|
'{{ value }}' => $ip,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidPrivateIpsV4()
|
public function getInvalidPrivateIpsV4()
|
||||||
@ -221,13 +207,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($ip, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $ip,
|
'{{ value }}' => $ip,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidReservedIpsV4()
|
public function getInvalidReservedIpsV4()
|
||||||
@ -249,13 +233,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($ip, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $ip,
|
'{{ value }}' => $ip,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidPublicIpsV4()
|
public function getInvalidPublicIpsV4()
|
||||||
@ -273,13 +255,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($ip, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $ip,
|
'{{ value }}' => $ip,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidIpsV6()
|
public function getInvalidIpsV6()
|
||||||
@ -311,13 +291,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($ip, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $ip,
|
'{{ value }}' => $ip,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidPrivateIpsV6()
|
public function getInvalidPrivateIpsV6()
|
||||||
@ -339,13 +317,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($ip, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $ip,
|
'{{ value }}' => $ip,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidReservedIpsV6()
|
public function getInvalidReservedIpsV6()
|
||||||
@ -366,13 +342,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($ip, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $ip,
|
'{{ value }}' => $ip,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidPublicIpsV6()
|
public function getInvalidPublicIpsV6()
|
||||||
@ -390,13 +364,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($ip, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $ip,
|
'{{ value }}' => $ip,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidIpsAll()
|
public function getInvalidIpsAll()
|
||||||
@ -414,13 +386,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($ip, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $ip,
|
'{{ value }}' => $ip,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidPrivateIpsAll()
|
public function getInvalidPrivateIpsAll()
|
||||||
@ -438,13 +408,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($ip, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $ip,
|
'{{ value }}' => $ip,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidReservedIpsAll()
|
public function getInvalidReservedIpsAll()
|
||||||
@ -462,13 +430,11 @@ class IpValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage',
|
'message' => 'myMessage',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($ip, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $ip,
|
'{{ value }}' => $ip,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidPublicIpsAll()
|
public function getInvalidPublicIpsAll()
|
||||||
|
@ -13,20 +13,21 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Isbn;
|
use Symfony\Component\Validator\Constraints\Isbn;
|
||||||
use Symfony\Component\Validator\Constraints\IsbnValidator;
|
use Symfony\Component\Validator\Constraints\IsbnValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see https://en.wikipedia.org/wiki/Isbn
|
* @see https://en.wikipedia.org/wiki/Isbn
|
||||||
*/
|
*/
|
||||||
class IsbnValidatorTest extends \PHPUnit_Framework_TestCase
|
class IsbnValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new IsbnValidator();
|
}
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new IsbnValidator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidIsbn10()
|
public function getValidIsbn10()
|
||||||
@ -116,21 +117,19 @@ class IsbnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$constraint = new Isbn(true);
|
$constraint = new Isbn(true);
|
||||||
$this->context
|
|
||||||
->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, $constraint);
|
$this->validator->validate(null, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringIsValid()
|
public function testEmptyStringIsValid()
|
||||||
{
|
{
|
||||||
$constraint = new Isbn(true);
|
$constraint = new Isbn(true);
|
||||||
$this->context
|
|
||||||
->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', $constraint);
|
$this->validator->validate('', $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,6 +138,7 @@ class IsbnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testExpectsStringCompatibleType()
|
public function testExpectsStringCompatibleType()
|
||||||
{
|
{
|
||||||
$constraint = new Isbn(true);
|
$constraint = new Isbn(true);
|
||||||
|
|
||||||
$this->validator->validate(new \stdClass(), $constraint);
|
$this->validator->validate(new \stdClass(), $constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,12 +147,13 @@ class IsbnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidIsbn10($isbn)
|
public function testValidIsbn10($isbn)
|
||||||
{
|
{
|
||||||
$constraint = new Isbn(array('type' => 'isbn10'));
|
$constraint = new Isbn(array(
|
||||||
$this->context
|
'type' => 'isbn10'
|
||||||
->expects($this->never())
|
));
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($isbn, $constraint);
|
$this->validator->validate($isbn, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,13 +161,14 @@ class IsbnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidIsbn10($isbn)
|
public function testInvalidIsbn10($isbn)
|
||||||
{
|
{
|
||||||
$constraint = new Isbn(array('type' => 'isbn10'));
|
$constraint = new Isbn(array(
|
||||||
$this->context
|
'type' => 'isbn10',
|
||||||
->expects($this->once())
|
'isbn10Message' => 'myMessage',
|
||||||
->method('addViolation')
|
));
|
||||||
->with($constraint->isbn10Message);
|
|
||||||
|
|
||||||
$this->validator->validate($isbn, $constraint);
|
$this->validator->validate($isbn, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,11 +177,10 @@ class IsbnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testValidIsbn13($isbn)
|
public function testValidIsbn13($isbn)
|
||||||
{
|
{
|
||||||
$constraint = new Isbn(array('type' => 'isbn13'));
|
$constraint = new Isbn(array('type' => 'isbn13'));
|
||||||
$this->context
|
|
||||||
->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($isbn, $constraint);
|
$this->validator->validate($isbn, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -187,13 +188,14 @@ class IsbnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidIsbn13($isbn)
|
public function testInvalidIsbn13($isbn)
|
||||||
{
|
{
|
||||||
$constraint = new Isbn(array('type' => 'isbn13'));
|
$constraint = new Isbn(array(
|
||||||
$this->context
|
'type' => 'isbn13',
|
||||||
->expects($this->once())
|
'isbn13Message' => 'myMessage',
|
||||||
->method('addViolation')
|
));
|
||||||
->with($constraint->isbn13Message);
|
|
||||||
|
|
||||||
$this->validator->validate($isbn, $constraint);
|
$this->validator->validate($isbn, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,11 +204,10 @@ class IsbnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testValidIsbn($isbn)
|
public function testValidIsbn($isbn)
|
||||||
{
|
{
|
||||||
$constraint = new Isbn();
|
$constraint = new Isbn();
|
||||||
$this->context
|
|
||||||
->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($isbn, $constraint);
|
$this->validator->validate($isbn, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -214,12 +215,12 @@ class IsbnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidIsbn($isbn)
|
public function testInvalidIsbn($isbn)
|
||||||
{
|
{
|
||||||
$constraint = new Isbn();
|
$constraint = new Isbn(array(
|
||||||
$this->context
|
'bothIsbnMessage' => 'myMessage',
|
||||||
->expects($this->once())
|
));
|
||||||
->method('addViolation')
|
|
||||||
->with($constraint->bothIsbnMessage);
|
|
||||||
|
|
||||||
$this->validator->validate($isbn, $constraint);
|
$this->validator->validate($isbn, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,20 +13,21 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Issn;
|
use Symfony\Component\Validator\Constraints\Issn;
|
||||||
use Symfony\Component\Validator\Constraints\IssnValidator;
|
use Symfony\Component\Validator\Constraints\IssnValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see https://en.wikipedia.org/wiki/Issn
|
* @see https://en.wikipedia.org/wiki/Issn
|
||||||
*/
|
*/
|
||||||
class IssnValidatorTest extends \PHPUnit_Framework_TestCase
|
class IssnValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
{
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
return Validation::API_VERSION_2_5;
|
||||||
$this->validator = new IssnValidator();
|
}
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new IssnValidator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidLowerCasedIssn()
|
public function getValidLowerCasedIssn()
|
||||||
@ -110,21 +111,19 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$constraint = new Issn();
|
$constraint = new Issn();
|
||||||
$this->context
|
|
||||||
->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, $constraint);
|
$this->validator->validate(null, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringIsValid()
|
public function testEmptyStringIsValid()
|
||||||
{
|
{
|
||||||
$constraint = new Issn();
|
$constraint = new Issn();
|
||||||
$this->context
|
|
||||||
->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', $constraint);
|
$this->validator->validate('', $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,13 +140,14 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCaseSensitiveIssns($issn)
|
public function testCaseSensitiveIssns($issn)
|
||||||
{
|
{
|
||||||
$constraint = new Issn(array('caseSensitive' => true));
|
$constraint = new Issn(array(
|
||||||
$this->context
|
'caseSensitive' => true,
|
||||||
->expects($this->once())
|
'message' => 'myMessage',
|
||||||
->method('addViolation')
|
));
|
||||||
->with($constraint->message);
|
|
||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -155,13 +155,14 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRequireHyphenIssns($issn)
|
public function testRequireHyphenIssns($issn)
|
||||||
{
|
{
|
||||||
$constraint = new Issn(array('requireHyphen' => true));
|
$constraint = new Issn(array(
|
||||||
$this->context
|
'requireHyphen' => true,
|
||||||
->expects($this->once())
|
'message' => 'myMessage',
|
||||||
->method('addViolation')
|
));
|
||||||
->with($constraint->message);
|
|
||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,11 +171,10 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testValidIssn($issn)
|
public function testValidIssn($issn)
|
||||||
{
|
{
|
||||||
$constraint = new Issn();
|
$constraint = new Issn();
|
||||||
$this->context
|
|
||||||
->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -182,13 +182,13 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidFormatIssn($issn)
|
public function testInvalidFormatIssn($issn)
|
||||||
{
|
{
|
||||||
$constraint = new Issn();
|
$constraint = new Issn(array(
|
||||||
$this->context
|
'message' => 'myMessage',
|
||||||
->expects($this->once())
|
));
|
||||||
->method('addViolation')
|
|
||||||
->with($constraint->message);
|
|
||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -196,13 +196,13 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidValueIssn($issn)
|
public function testInvalidValueIssn($issn)
|
||||||
{
|
{
|
||||||
$constraint = new Issn();
|
$constraint = new Issn(array(
|
||||||
$this->context
|
'message' => 'myMessage',
|
||||||
->expects($this->once())
|
));
|
||||||
->method('addViolation')
|
|
||||||
->with($constraint->message);
|
|
||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -210,11 +210,12 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidIssn($issn)
|
public function testInvalidIssn($issn)
|
||||||
{
|
{
|
||||||
$constraint = new Issn();
|
$constraint = new Issn(array(
|
||||||
$this->context
|
'message' => 'myMessage',
|
||||||
->expects($this->once())
|
));
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
|
|
||||||
|
$this->assertViolation('myMessage');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,41 +14,39 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
use Symfony\Component\Intl\Util\IntlTestHelper;
|
use Symfony\Component\Intl\Util\IntlTestHelper;
|
||||||
use Symfony\Component\Validator\Constraints\Language;
|
use Symfony\Component\Validator\Constraints\Language;
|
||||||
use Symfony\Component\Validator\Constraints\LanguageValidator;
|
use Symfony\Component\Validator\Constraints\LanguageValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
class LanguageValidatorTest extends \PHPUnit_Framework_TestCase
|
class LanguageValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
protected $context;
|
protected function getApiVersion()
|
||||||
protected $validator;
|
{
|
||||||
|
return Validation::API_VERSION_2_5;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new LanguageValidator();
|
||||||
|
}
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
IntlTestHelper::requireFullIntl($this);
|
IntlTestHelper::requireFullIntl($this);
|
||||||
|
|
||||||
$this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false);
|
parent::setUp();
|
||||||
$this->validator = new LanguageValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function tearDown()
|
|
||||||
{
|
|
||||||
$this->context = null;
|
|
||||||
$this->validator = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullIsValid()
|
public function testNullIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate(null, new Language());
|
$this->validator->validate(null, new Language());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyStringIsValid()
|
public function testEmptyStringIsValid()
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate('', new Language());
|
$this->validator->validate('', new Language());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,10 +62,9 @@ class LanguageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testValidLanguages($language)
|
public function testValidLanguages($language)
|
||||||
{
|
{
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($language, new Language());
|
$this->validator->validate($language, new Language());
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidLanguages()
|
public function getValidLanguages()
|
||||||
@ -88,13 +85,11 @@ class LanguageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'myMessage'
|
'message' => 'myMessage'
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->context->expects($this->once())
|
$this->validator->validate($language, $constraint);
|
||||||
->method('addViolation')
|
|
||||||
->with('myMessage', array(
|
$this->assertViolation('myMessage', array(
|
||||||
'{{ value }}' => $language,
|
'{{ value }}' => $language,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->validator->validate($language, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidLanguages()
|
public function getInvalidLanguages()
|
||||||
@ -109,11 +104,11 @@ class LanguageValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
\Locale::setDefault('fr_FR');
|
\Locale::setDefault('fr_FR');
|
||||||
$existingLanguage = 'en';
|
$existingLanguage = 'en';
|
||||||
$this->context->expects($this->never())
|
|
||||||
->method('addViolation');
|
|
||||||
|
|
||||||
$this->validator->validate($existingLanguage, new Language(array(
|
$this->validator->validate($existingLanguage, new Language(array(
|
||||||
'message' => 'aMessage'
|
'message' => 'aMessage'
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$this->assertNoViolation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraints\LegacyAllValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyAllValidator2Dot4ApiTest extends AllValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new LegacyAllValidator();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyAllValidatorLegacyApiTest extends AllValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyBlankValidator2Dot4ApiTest extends BlankValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyBlankValidatorLegacyApiTest extends BlankValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyCallbackValidator2Dot4ApiTest extends CallbackValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyCallbackValidatorLegacyApiTest extends CallbackValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyCardSchemeValidator2Dot4ApiTest extends CardSchemeValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyCardSchemeValidatorLegacyApiTest extends CardSchemeValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraints\LegacyChoiceValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyChoiceValidator2Dot4ApiTest extends ChoiceValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new LegacyChoiceValidator();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyChoiceValidatorLegacyApiTest extends ChoiceValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraints\LegacyCollectionValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
class LegacyCollectionValidatorArray2Dot4ApiTest extends CollectionValidatorArrayTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new LegacyCollectionValidator();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
class LegacyCollectionValidatorArrayLegacyApiTest extends CollectionValidatorArrayTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraints\LegacyCollectionValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
class LegacyCollectionValidatorArrayObject2Dot4ApiTest extends CollectionValidatorArrayObjectTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new LegacyCollectionValidator();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
class LegacyCollectionValidatorArrayObjectLegacyApiTest extends CollectionValidatorArrayObjectTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraints\LegacyCollectionValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
class LegacyCollectionValidatorCustomArrayObject2Dot4ApiTest extends CollectionValidatorCustomArrayObjectTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new LegacyCollectionValidator();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
class LegacyCollectionValidatorCustomArrayObjectLegacyApiTest extends CollectionValidatorCustomArrayObjectTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraints\LegacyCountValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyCountValidatorArray2Dot4ApiTest extends CountValidatorArrayTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new LegacyCountValidator();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyCountValidatorArrayLegacyApiTest extends CountValidatorArrayTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraints\LegacyCountValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyCountValidatorCountable2Dot4ApiTest extends CountValidatorCountableTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new LegacyCountValidator();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyCountValidatorCountableLegacyApiTest extends CountValidatorCountableTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyCurrencyValidator2Dot4ApiTest extends CurrencyValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyCurrencyValidatorLegacyApiTest extends CurrencyValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyDateTimeValidator2Dot4ApiTest extends DateTimeValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyDateTimeValidatorLegacyApiTest extends DateTimeValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyDateValidator2Dot4ApiTest extends DateValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyDateValidatorLegacyApiTest extends DateValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyEmailValidator2Dot4ApiTest extends EmailValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyEmailValidatorLegacyApiTest extends EmailValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyEqualToValidator2Dot4ApiTest extends EqualToValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyEqualToValidatorLegacyApiTest extends EqualToValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyExpressionValidator2Dot4ApiTest extends ExpressionValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyExpressionValidatorLegacyApiTest extends ExpressionValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyFalseValidator2Dot4ApiTest extends FalseValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyFalseValidatorLegacyApiTest extends FalseValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyFileValidatorObject2Dot4ApiTest extends FileValidatorObjectTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyFileValidatorObjectLegacyApiTest extends FileValidatorObjectTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyFileValidatorPath2Dot4ApiTest extends FileValidatorPathTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyFileValidatorPathLegacyApiTest extends FileValidatorPathTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyGreaterThanOrEqualValidator2Dot4ApiTest extends GreaterThanOrEqualValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyGreaterThanOrEqualValidatorLegacyApiTest extends GreaterThanOrEqualValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyGreaterThanValidator2Dot4ApiTest extends GreaterThanValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyGreaterThanValidatorLegacyApiTest extends GreaterThanValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyIbanValidator2Dot4ApiTest extends IbanValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyIbanValidatorLegacyApiTest extends IbanValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyIdenticalToValidator2Dot4ApiTest extends IdenticalToValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyIdenticalToValidatorLegacyApiTest extends IdenticalToValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyImageValidator2Dot4ApiTest extends ImageValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyImageValidatorLegacyApiTest extends ImageValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyIpValidator2Dot4ApiTest extends IpValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyIpValidatorLegacyApiTest extends IpValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyIsbnValidator2Dot4ApiTest extends IsbnValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyIsbnValidatorLegacyApiTest extends IsbnValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyIssnValidator2Dot4ApiTest extends IssnValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyIssnValidatorLegacyApiTest extends IssnValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyLanguageValidator2Dot4ApiTest extends LanguageValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyLanguageValidatorLegacyApiTest extends LanguageValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraints\LegacyLengthValidator;
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyLengthValidator2Dot4ApiTest extends LengthValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createValidator()
|
||||||
|
{
|
||||||
|
return new LegacyLengthValidator();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyLengthValidatorLegacyApiTest extends LengthValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyLessThanOrEqualValidator2Dot4ApiTest extends LessThanOrEqualValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyLessThanOrEqualValidatorLegacyApiTest extends LessThanOrEqualValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyLessThanValidator2Dot4ApiTest extends LessThanValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyLessThanValidatorLegacyApiTest extends LessThanValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_5_BC;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.5.3
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class LegacyLocaleValidator2Dot4ApiTest extends LocaleValidatorTest
|
||||||
|
{
|
||||||
|
protected function getApiVersion()
|
||||||
|
{
|
||||||
|
return Validation::API_VERSION_2_4;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user