Move Constraint validator test case to Test namespace
This commit is contained in:
parent
b4b1fef7a3
commit
e938361cf7
@ -6,3 +6,33 @@ DependencyInjection
|
|||||||
|
|
||||||
* Calling `get()` on a `ContainerBuilder` instance before compiling the
|
* Calling `get()` on a `ContainerBuilder` instance before compiling the
|
||||||
container is deprecated and will throw an exception in Symfony 4.0.
|
container is deprecated and will throw an exception in Symfony 4.0.
|
||||||
|
|
||||||
|
Validator
|
||||||
|
---------
|
||||||
|
|
||||||
|
* `Tests\Constraints\AbstractConstraintValidatorTest` has been deprecated in
|
||||||
|
favor of `Test\ConstraintValidatorTestCase`.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```php
|
||||||
|
// ...
|
||||||
|
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
|
||||||
|
|
||||||
|
class MyCustomValidatorTest extends AbstractConstraintValidatorTest
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```php
|
||||||
|
// ...
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
|
class MyCustomValidatorTest extends ConstraintValidatorTestCase
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
@ -199,3 +199,30 @@ Validator
|
|||||||
---------
|
---------
|
||||||
|
|
||||||
* The `DateTimeValidator::PATTERN` constant was removed.
|
* The `DateTimeValidator::PATTERN` constant was removed.
|
||||||
|
|
||||||
|
* `Tests\Constraints\AbstractConstraintValidatorTest` has been removed in
|
||||||
|
favor of `Test\ConstraintValidatorTestCase`.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```php
|
||||||
|
// ...
|
||||||
|
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
|
||||||
|
|
||||||
|
class MyCustomValidatorTest extends AbstractConstraintValidatorTest
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```php
|
||||||
|
// ...
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
|
class MyCustomValidatorTest extends ConstraintValidatorTestCase
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
@ -26,6 +26,8 @@ use Doctrine\ORM\Tools\SchemaTool;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
|
* @todo use ConstraintValidatorTestCase when symfony/validator ~3.2 is required.
|
||||||
*/
|
*/
|
||||||
class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
|
class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
|
@ -21,11 +21,12 @@ use Symfony\Component\Form\SubmitButtonBuilder;
|
|||||||
use Symfony\Component\Validator\Constraints\NotNull;
|
use Symfony\Component\Validator\Constraints\NotNull;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
use Symfony\Component\Validator\Constraints\Valid;
|
use Symfony\Component\Validator\Constraints\Valid;
|
||||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
|
||||||
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
|
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
|
* @todo use ConstraintValidatorTestCase when symfony/validator ~3.2 is required.
|
||||||
*/
|
*/
|
||||||
class FormValidatorTest extends AbstractConstraintValidatorTest
|
class FormValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
3.2.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* deprecated `Tests\Constraints\AbstractContraintValidatorTest` in favor of `Test\ConstraintValidatorTestCase`
|
||||||
|
|
||||||
3.1.0
|
3.1.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -0,0 +1,341 @@
|
|||||||
|
<?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\Test;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
use Symfony\Component\Validator\Constraints\NotNull;
|
||||||
|
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\Mapping\ClassMetadata;
|
||||||
|
use Symfony\Component\Validator\Mapping\PropertyMetadata;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A test case to ease testing Constraint Validators.
|
||||||
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
abstract class ConstraintValidatorTestCase 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 $constraint;
|
||||||
|
protected $defaultTimezone;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->group = 'MyGroup';
|
||||||
|
$this->metadata = null;
|
||||||
|
$this->object = null;
|
||||||
|
$this->value = 'InvalidValue';
|
||||||
|
$this->root = 'root';
|
||||||
|
$this->propertyPath = 'property.path';
|
||||||
|
|
||||||
|
// Initialize the context with some constraint so that we can
|
||||||
|
// successfully build a violation.
|
||||||
|
$this->constraint = new NotNull();
|
||||||
|
|
||||||
|
$this->context = $this->createContext();
|
||||||
|
$this->validator = $this->createValidator();
|
||||||
|
$this->validator->initialize($this->context);
|
||||||
|
|
||||||
|
\Locale::setDefault('en');
|
||||||
|
|
||||||
|
$this->setDefaultTimezone('UTC');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
$this->restoreDefaultTimezone();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setDefaultTimezone($defaultTimezone)
|
||||||
|
{
|
||||||
|
// Make sure this method can not be called twice before calling
|
||||||
|
// also restoreDefaultTimezone()
|
||||||
|
if (null === $this->defaultTimezone) {
|
||||||
|
$this->defaultTimezone = date_default_timezone_get();
|
||||||
|
date_default_timezone_set($defaultTimezone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function restoreDefaultTimezone()
|
||||||
|
{
|
||||||
|
if (null !== $this->defaultTimezone) {
|
||||||
|
date_default_timezone_set($this->defaultTimezone);
|
||||||
|
$this->defaultTimezone = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createContext()
|
||||||
|
{
|
||||||
|
$translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface');
|
||||||
|
$validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
|
||||||
|
$contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface');
|
||||||
|
|
||||||
|
$context = new ExecutionContext($validator, $this->root, $translator);
|
||||||
|
$context->setGroup($this->group);
|
||||||
|
$context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
||||||
|
$context->setConstraint($this->constraint);
|
||||||
|
|
||||||
|
$validator->expects($this->any())
|
||||||
|
->method('inContext')
|
||||||
|
->with($context)
|
||||||
|
->will($this->returnValue($contextualValidator));
|
||||||
|
|
||||||
|
return $context;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setGroup($group)
|
||||||
|
{
|
||||||
|
$this->group = $group;
|
||||||
|
$this->context->setGroup($group);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setObject($object)
|
||||||
|
{
|
||||||
|
$this->object = $object;
|
||||||
|
$this->metadata = is_object($object)
|
||||||
|
? new ClassMetadata(get_class($object))
|
||||||
|
: null;
|
||||||
|
|
||||||
|
$this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setProperty($object, $property)
|
||||||
|
{
|
||||||
|
$this->object = $object;
|
||||||
|
$this->metadata = is_object($object)
|
||||||
|
? new PropertyMetadata(get_class($object), $property)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
$this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setValue($value)
|
||||||
|
{
|
||||||
|
$this->value = $value;
|
||||||
|
$this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setRoot($root)
|
||||||
|
{
|
||||||
|
$this->root = $root;
|
||||||
|
$this->context = $this->createContext();
|
||||||
|
$this->validator->initialize($this->context);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setPropertyPath($propertyPath)
|
||||||
|
{
|
||||||
|
$this->propertyPath = $propertyPath;
|
||||||
|
$this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function expectNoValidate()
|
||||||
|
{
|
||||||
|
$validator = $this->context->getValidator()->inContext($this->context);
|
||||||
|
$validator->expects($this->never())
|
||||||
|
->method('atPath');
|
||||||
|
$validator->expects($this->never())
|
||||||
|
->method('validate');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function expectValidateAt($i, $propertyPath, $value, $group)
|
||||||
|
{
|
||||||
|
$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, $this->logicalOr(null, array(), $this->isInstanceOf('\Symfony\Component\Validator\Constraints\Valid')), $group);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function expectValidateValueAt($i, $propertyPath, $value, $constraints, $group = null)
|
||||||
|
{
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function assertNoViolation()
|
||||||
|
{
|
||||||
|
$this->assertSame(0, $violationsCount = count($this->context->getViolations()), sprintf('0 violation expected. Got %u.', $violationsCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $message
|
||||||
|
*
|
||||||
|
* @return ConstraintViolationAssertion
|
||||||
|
*/
|
||||||
|
protected function buildViolation($message)
|
||||||
|
{
|
||||||
|
return new ConstraintViolationAssertion($this->context, $message, $this->constraint);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract protected function createValidator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
class ConstraintViolationAssertion
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var ExecutionContextInterface
|
||||||
|
*/
|
||||||
|
private $context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ConstraintViolationAssertion[]
|
||||||
|
*/
|
||||||
|
private $assertions;
|
||||||
|
|
||||||
|
private $message;
|
||||||
|
private $parameters = array();
|
||||||
|
private $invalidValue = 'InvalidValue';
|
||||||
|
private $propertyPath = 'property.path';
|
||||||
|
private $translationDomain;
|
||||||
|
private $plural;
|
||||||
|
private $code;
|
||||||
|
private $constraint;
|
||||||
|
private $cause;
|
||||||
|
|
||||||
|
public function __construct(ExecutionContextInterface $context, $message, Constraint $constraint = null, array $assertions = array())
|
||||||
|
{
|
||||||
|
$this->context = $context;
|
||||||
|
$this->message = $message;
|
||||||
|
$this->constraint = $constraint;
|
||||||
|
$this->assertions = $assertions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function atPath($path)
|
||||||
|
{
|
||||||
|
$this->propertyPath = $path;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setParameter($key, $value)
|
||||||
|
{
|
||||||
|
$this->parameters[$key] = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setParameters(array $parameters)
|
||||||
|
{
|
||||||
|
$this->parameters = $parameters;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTranslationDomain($translationDomain)
|
||||||
|
{
|
||||||
|
$this->translationDomain = $translationDomain;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setInvalidValue($invalidValue)
|
||||||
|
{
|
||||||
|
$this->invalidValue = $invalidValue;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPlural($number)
|
||||||
|
{
|
||||||
|
$this->plural = $number;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCode($code)
|
||||||
|
{
|
||||||
|
$this->code = $code;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCause($cause)
|
||||||
|
{
|
||||||
|
$this->cause = $cause;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildNextViolation($message)
|
||||||
|
{
|
||||||
|
$assertions = $this->assertions;
|
||||||
|
$assertions[] = $this;
|
||||||
|
|
||||||
|
return new self($this->context, $message, $this->constraint, $assertions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertRaised()
|
||||||
|
{
|
||||||
|
$expected = array();
|
||||||
|
foreach ($this->assertions as $assertion) {
|
||||||
|
$expected[] = $assertion->getViolation();
|
||||||
|
}
|
||||||
|
$expected[] = $this->getViolation();
|
||||||
|
|
||||||
|
$violations = iterator_to_array($this->context->getViolations());
|
||||||
|
|
||||||
|
\PHPUnit_Framework_Assert::assertSame($expectedCount = count($expected), $violationsCount = count($violations), sprintf('%u violation(s) expected. Got %u.', $expectedCount, $violationsCount));
|
||||||
|
|
||||||
|
reset($violations);
|
||||||
|
|
||||||
|
foreach ($expected as $violation) {
|
||||||
|
\PHPUnit_Framework_Assert::assertEquals($violation, current($violations));
|
||||||
|
next($violations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getViolation()
|
||||||
|
{
|
||||||
|
return new ConstraintViolation(
|
||||||
|
null,
|
||||||
|
$this->message,
|
||||||
|
$this->parameters,
|
||||||
|
$this->context->getRoot(),
|
||||||
|
$this->propertyPath,
|
||||||
|
$this->invalidValue,
|
||||||
|
$this->plural,
|
||||||
|
$this->code,
|
||||||
|
$this->constraint,
|
||||||
|
$this->cause
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Intl\Util\IntlTestHelper;
|
use Symfony\Component\Intl\Util\IntlTestHelper;
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class ComparisonTest_Class
|
class ComparisonTest_Class
|
||||||
{
|
{
|
||||||
@ -32,7 +33,7 @@ class ComparisonTest_Class
|
|||||||
/**
|
/**
|
||||||
* @author Daniel Holmes <daniel@danielholmes.org>
|
* @author Daniel Holmes <daniel@danielholmes.org>
|
||||||
*/
|
*/
|
||||||
abstract class AbstractComparisonValidatorTestCase extends AbstractConstraintValidatorTest
|
abstract class AbstractComparisonValidatorTestCase extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected static function addPhp5Dot5Comparisons(array $comparisons)
|
protected static function addPhp5Dot5Comparisons(array $comparisons)
|
||||||
{
|
{
|
||||||
|
@ -11,331 +11,11 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Validator\Tests\Constraints;
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
use Symfony\Component\Validator\Constraints\NotNull;
|
|
||||||
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\Mapping\ClassMetadata;
|
|
||||||
use Symfony\Component\Validator\Mapping\PropertyMetadata;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 2.5.3
|
* @deprecated Since Symfony 3.2, use ConstraintValidatorTestCase instead.
|
||||||
*
|
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
|
||||||
*/
|
*/
|
||||||
abstract class AbstractConstraintValidatorTest extends \PHPUnit_Framework_TestCase
|
abstract class AbstractConstraintValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var ExecutionContextInterface
|
|
||||||
*/
|
|
||||||
protected $context;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var ConstraintValidatorInterface
|
|
||||||
*/
|
|
||||||
protected $validator;
|
|
||||||
|
|
||||||
protected $group;
|
|
||||||
protected $metadata;
|
|
||||||
protected $object;
|
|
||||||
protected $value;
|
|
||||||
protected $root;
|
|
||||||
protected $propertyPath;
|
|
||||||
protected $constraint;
|
|
||||||
protected $defaultTimezone;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
|
||||||
$this->group = 'MyGroup';
|
|
||||||
$this->metadata = null;
|
|
||||||
$this->object = null;
|
|
||||||
$this->value = 'InvalidValue';
|
|
||||||
$this->root = 'root';
|
|
||||||
$this->propertyPath = 'property.path';
|
|
||||||
|
|
||||||
// Initialize the context with some constraint so that we can
|
|
||||||
// successfully build a violation.
|
|
||||||
$this->constraint = new NotNull();
|
|
||||||
|
|
||||||
$this->context = $this->createContext();
|
|
||||||
$this->validator = $this->createValidator();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
|
|
||||||
\Locale::setDefault('en');
|
|
||||||
|
|
||||||
$this->setDefaultTimezone('UTC');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function tearDown()
|
|
||||||
{
|
|
||||||
$this->restoreDefaultTimezone();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setDefaultTimezone($defaultTimezone)
|
|
||||||
{
|
|
||||||
// Make sure this method can not be called twice before calling
|
|
||||||
// also restoreDefaultTimezone()
|
|
||||||
if (null === $this->defaultTimezone) {
|
|
||||||
$this->defaultTimezone = date_default_timezone_get();
|
|
||||||
date_default_timezone_set($defaultTimezone);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function restoreDefaultTimezone()
|
|
||||||
{
|
|
||||||
if (null !== $this->defaultTimezone) {
|
|
||||||
date_default_timezone_set($this->defaultTimezone);
|
|
||||||
$this->defaultTimezone = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function createContext()
|
|
||||||
{
|
|
||||||
$translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface');
|
|
||||||
$validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
|
|
||||||
$contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface');
|
|
||||||
|
|
||||||
$context = new ExecutionContext($validator, $this->root, $translator);
|
|
||||||
$context->setGroup($this->group);
|
|
||||||
$context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
|
||||||
$context->setConstraint($this->constraint);
|
|
||||||
|
|
||||||
$validator->expects($this->any())
|
|
||||||
->method('inContext')
|
|
||||||
->with($context)
|
|
||||||
->will($this->returnValue($contextualValidator));
|
|
||||||
|
|
||||||
return $context;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setGroup($group)
|
|
||||||
{
|
|
||||||
$this->group = $group;
|
|
||||||
$this->context->setGroup($group);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setObject($object)
|
|
||||||
{
|
|
||||||
$this->object = $object;
|
|
||||||
$this->metadata = is_object($object)
|
|
||||||
? new ClassMetadata(get_class($object))
|
|
||||||
: null;
|
|
||||||
|
|
||||||
$this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setProperty($object, $property)
|
|
||||||
{
|
|
||||||
$this->object = $object;
|
|
||||||
$this->metadata = is_object($object)
|
|
||||||
? new PropertyMetadata(get_class($object), $property)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
$this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setValue($value)
|
|
||||||
{
|
|
||||||
$this->value = $value;
|
|
||||||
$this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setRoot($root)
|
|
||||||
{
|
|
||||||
$this->root = $root;
|
|
||||||
$this->context = $this->createContext();
|
|
||||||
$this->validator->initialize($this->context);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setPropertyPath($propertyPath)
|
|
||||||
{
|
|
||||||
$this->propertyPath = $propertyPath;
|
|
||||||
$this->context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function expectNoValidate()
|
|
||||||
{
|
|
||||||
$validator = $this->context->getValidator()->inContext($this->context);
|
|
||||||
$validator->expects($this->never())
|
|
||||||
->method('atPath');
|
|
||||||
$validator->expects($this->never())
|
|
||||||
->method('validate');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function expectValidateAt($i, $propertyPath, $value, $group)
|
|
||||||
{
|
|
||||||
$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, $this->logicalOr(null, array(), $this->isInstanceOf('\Symfony\Component\Validator\Constraints\Valid')), $group);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function expectValidateValueAt($i, $propertyPath, $value, $constraints, $group = null)
|
|
||||||
{
|
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function assertNoViolation()
|
|
||||||
{
|
|
||||||
$this->assertSame(0, $violationsCount = count($this->context->getViolations()), sprintf('0 violation expected. Got %u.', $violationsCount));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $message
|
|
||||||
*
|
|
||||||
* @return ConstraintViolationAssertion
|
|
||||||
*/
|
|
||||||
protected function buildViolation($message)
|
|
||||||
{
|
|
||||||
return new ConstraintViolationAssertion($this->context, $message, $this->constraint);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract protected function createValidator();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
class ConstraintViolationAssertion
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var ExecutionContextInterface
|
|
||||||
*/
|
|
||||||
private $context;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var ConstraintViolationAssertion[]
|
|
||||||
*/
|
|
||||||
private $assertions;
|
|
||||||
|
|
||||||
private $message;
|
|
||||||
private $parameters = array();
|
|
||||||
private $invalidValue = 'InvalidValue';
|
|
||||||
private $propertyPath = 'property.path';
|
|
||||||
private $translationDomain;
|
|
||||||
private $plural;
|
|
||||||
private $code;
|
|
||||||
private $constraint;
|
|
||||||
private $cause;
|
|
||||||
|
|
||||||
public function __construct(ExecutionContextInterface $context, $message, Constraint $constraint = null, array $assertions = array())
|
|
||||||
{
|
|
||||||
$this->context = $context;
|
|
||||||
$this->message = $message;
|
|
||||||
$this->constraint = $constraint;
|
|
||||||
$this->assertions = $assertions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function atPath($path)
|
|
||||||
{
|
|
||||||
$this->propertyPath = $path;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setParameter($key, $value)
|
|
||||||
{
|
|
||||||
$this->parameters[$key] = $value;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setParameters(array $parameters)
|
|
||||||
{
|
|
||||||
$this->parameters = $parameters;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTranslationDomain($translationDomain)
|
|
||||||
{
|
|
||||||
$this->translationDomain = $translationDomain;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setInvalidValue($invalidValue)
|
|
||||||
{
|
|
||||||
$this->invalidValue = $invalidValue;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setPlural($number)
|
|
||||||
{
|
|
||||||
$this->plural = $number;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCode($code)
|
|
||||||
{
|
|
||||||
$this->code = $code;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCause($cause)
|
|
||||||
{
|
|
||||||
$this->cause = $cause;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildNextViolation($message)
|
|
||||||
{
|
|
||||||
$assertions = $this->assertions;
|
|
||||||
$assertions[] = $this;
|
|
||||||
|
|
||||||
return new self($this->context, $message, $this->constraint, $assertions);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function assertRaised()
|
|
||||||
{
|
|
||||||
$expected = array();
|
|
||||||
foreach ($this->assertions as $assertion) {
|
|
||||||
$expected[] = $assertion->getViolation();
|
|
||||||
}
|
|
||||||
$expected[] = $this->getViolation();
|
|
||||||
|
|
||||||
$violations = iterator_to_array($this->context->getViolations());
|
|
||||||
|
|
||||||
\PHPUnit_Framework_Assert::assertSame($expectedCount = count($expected), $violationsCount = count($violations), sprintf('%u violation(s) expected. Got %u.', $expectedCount, $violationsCount));
|
|
||||||
|
|
||||||
reset($violations);
|
|
||||||
|
|
||||||
foreach ($expected as $violation) {
|
|
||||||
\PHPUnit_Framework_Assert::assertEquals($violation, current($violations));
|
|
||||||
next($violations);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getViolation()
|
|
||||||
{
|
|
||||||
return new ConstraintViolation(
|
|
||||||
null,
|
|
||||||
$this->message,
|
|
||||||
$this->parameters,
|
|
||||||
$this->context->getRoot(),
|
|
||||||
$this->propertyPath,
|
|
||||||
$this->invalidValue,
|
|
||||||
$this->plural,
|
|
||||||
$this->code,
|
|
||||||
$this->constraint,
|
|
||||||
$this->cause
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,9 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class AllValidatorTest extends AbstractConstraintValidatorTest
|
class AllValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\BicValidator;
|
use Symfony\Component\Validator\Constraints\BicValidator;
|
||||||
use Symfony\Component\Validator\Constraints\Bic;
|
use Symfony\Component\Validator\Constraints\Bic;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class BicValidatorTest extends AbstractConstraintValidatorTest
|
class BicValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class BlankValidatorTest extends AbstractConstraintValidatorTest
|
class BlankValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,7 @@ 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\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class CallbackValidatorTest_Class
|
class CallbackValidatorTest_Class
|
||||||
{
|
{
|
||||||
@ -43,7 +44,7 @@ class CallbackValidatorTest_Object
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CallbackValidatorTest extends AbstractConstraintValidatorTest
|
class CallbackValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class CardSchemeValidatorTest extends AbstractConstraintValidatorTest
|
class CardSchemeValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,13 +13,14 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
function choice_callback()
|
function choice_callback()
|
||||||
{
|
{
|
||||||
return array('foo', 'bar');
|
return array('foo', 'bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChoiceValidatorTest extends AbstractConstraintValidatorTest
|
class ChoiceValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -17,8 +17,9 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
abstract class CollectionValidatorTest extends AbstractConstraintValidatorTest
|
abstract class CollectionValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,11 +13,12 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
abstract class CountValidatorTest extends AbstractConstraintValidatorTest
|
abstract class CountValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -14,8 +14,9 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class CountryValidatorTest extends AbstractConstraintValidatorTest
|
class CountryValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -14,8 +14,9 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class CurrencyValidatorTest extends AbstractConstraintValidatorTest
|
class CurrencyValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class DateTimeValidatorTest extends AbstractConstraintValidatorTest
|
class DateTimeValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class DateValidatorTest extends AbstractConstraintValidatorTest
|
class DateValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -14,11 +14,12 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
use Symfony\Bridge\PhpUnit\DnsMock;
|
use Symfony\Bridge\PhpUnit\DnsMock;
|
||||||
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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group dns-sensitive
|
* @group dns-sensitive
|
||||||
*/
|
*/
|
||||||
class EmailValidatorTest extends AbstractConstraintValidatorTest
|
class EmailValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,9 +13,10 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
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\Test\ConstraintValidatorTestCase;
|
||||||
use Symfony\Component\Validator\Tests\Fixtures\Entity;
|
use Symfony\Component\Validator\Tests\Fixtures\Entity;
|
||||||
|
|
||||||
class ExpressionValidatorTest extends AbstractConstraintValidatorTest
|
class ExpressionValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -14,8 +14,9 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
abstract class FileValidatorTest extends AbstractConstraintValidatorTest
|
abstract class FileValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected $path;
|
protected $path;
|
||||||
|
|
||||||
|
@ -13,8 +13,9 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class IbanValidatorTest extends AbstractConstraintValidatorTest
|
class IbanValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,11 +13,12 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires extension fileinfo
|
* @requires extension fileinfo
|
||||||
*/
|
*/
|
||||||
class ImageValidatorTest extends AbstractConstraintValidatorTest
|
class ImageValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected $context;
|
protected $context;
|
||||||
|
|
||||||
|
@ -13,8 +13,9 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class IpValidatorTest extends AbstractConstraintValidatorTest
|
class IpValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\IsFalse;
|
use Symfony\Component\Validator\Constraints\IsFalse;
|
||||||
use Symfony\Component\Validator\Constraints\IsFalseValidator;
|
use Symfony\Component\Validator\Constraints\IsFalseValidator;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class IsFalseValidatorTest extends AbstractConstraintValidatorTest
|
class IsFalseValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\IsNull;
|
use Symfony\Component\Validator\Constraints\IsNull;
|
||||||
use Symfony\Component\Validator\Constraints\IsNullValidator;
|
use Symfony\Component\Validator\Constraints\IsNullValidator;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class IsNullValidatorTest extends AbstractConstraintValidatorTest
|
class IsNullValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\IsTrue;
|
use Symfony\Component\Validator\Constraints\IsTrue;
|
||||||
use Symfony\Component\Validator\Constraints\IsTrueValidator;
|
use Symfony\Component\Validator\Constraints\IsTrueValidator;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class IsTrueValidatorTest extends AbstractConstraintValidatorTest
|
class IsTrueValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,11 +13,12 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see https://en.wikipedia.org/wiki/Isbn
|
* @see https://en.wikipedia.org/wiki/Isbn
|
||||||
*/
|
*/
|
||||||
class IsbnValidatorTest extends AbstractConstraintValidatorTest
|
class IsbnValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,11 +13,12 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see https://en.wikipedia.org/wiki/Issn
|
* @see https://en.wikipedia.org/wiki/Issn
|
||||||
*/
|
*/
|
||||||
class IssnValidatorTest extends AbstractConstraintValidatorTest
|
class IssnValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -14,8 +14,9 @@ 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\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class LanguageValidatorTest extends AbstractConstraintValidatorTest
|
class LanguageValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Length;
|
use Symfony\Component\Validator\Constraints\Length;
|
||||||
use Symfony\Component\Validator\Constraints\LengthValidator;
|
use Symfony\Component\Validator\Constraints\LengthValidator;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class LengthValidatorTest extends AbstractConstraintValidatorTest
|
class LengthValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Locale;
|
use Symfony\Component\Validator\Constraints\Locale;
|
||||||
use Symfony\Component\Validator\Constraints\LocaleValidator;
|
use Symfony\Component\Validator\Constraints\LocaleValidator;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class LocaleValidatorTest extends AbstractConstraintValidatorTest
|
class LocaleValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Luhn;
|
use Symfony\Component\Validator\Constraints\Luhn;
|
||||||
use Symfony\Component\Validator\Constraints\LuhnValidator;
|
use Symfony\Component\Validator\Constraints\LuhnValidator;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class LuhnValidatorTest extends AbstractConstraintValidatorTest
|
class LuhnValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlankValidator;
|
use Symfony\Component\Validator\Constraints\NotBlankValidator;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class NotBlankValidatorTest extends AbstractConstraintValidatorTest
|
class NotBlankValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\NotNull;
|
use Symfony\Component\Validator\Constraints\NotNull;
|
||||||
use Symfony\Component\Validator\Constraints\NotNullValidator;
|
use Symfony\Component\Validator\Constraints\NotNullValidator;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class NotNullValidatorTest extends AbstractConstraintValidatorTest
|
class NotNullValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -14,8 +14,9 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
use Symfony\Component\Intl\Util\IntlTestHelper;
|
use Symfony\Component\Intl\Util\IntlTestHelper;
|
||||||
use Symfony\Component\Validator\Constraints\Range;
|
use Symfony\Component\Validator\Constraints\Range;
|
||||||
use Symfony\Component\Validator\Constraints\RangeValidator;
|
use Symfony\Component\Validator\Constraints\RangeValidator;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class RangeValidatorTest extends AbstractConstraintValidatorTest
|
class RangeValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Regex;
|
use Symfony\Component\Validator\Constraints\Regex;
|
||||||
use Symfony\Component\Validator\Constraints\RegexValidator;
|
use Symfony\Component\Validator\Constraints\RegexValidator;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class RegexValidatorTest extends AbstractConstraintValidatorTest
|
class RegexValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Time;
|
use Symfony\Component\Validator\Constraints\Time;
|
||||||
use Symfony\Component\Validator\Constraints\TimeValidator;
|
use Symfony\Component\Validator\Constraints\TimeValidator;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class TimeValidatorTest extends AbstractConstraintValidatorTest
|
class TimeValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,9 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Type;
|
use Symfony\Component\Validator\Constraints\Type;
|
||||||
use Symfony\Component\Validator\Constraints\TypeValidator;
|
use Symfony\Component\Validator\Constraints\TypeValidator;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
class TypeValidatorTest extends AbstractConstraintValidatorTest
|
class TypeValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected static $file;
|
protected static $file;
|
||||||
|
|
||||||
|
@ -14,11 +14,12 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
use Symfony\Bridge\PhpUnit\DnsMock;
|
use Symfony\Bridge\PhpUnit\DnsMock;
|
||||||
use Symfony\Component\Validator\Constraints\Url;
|
use Symfony\Component\Validator\Constraints\Url;
|
||||||
use Symfony\Component\Validator\Constraints\UrlValidator;
|
use Symfony\Component\Validator\Constraints\UrlValidator;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group dns-sensitive
|
* @group dns-sensitive
|
||||||
*/
|
*/
|
||||||
class UrlValidatorTest extends AbstractConstraintValidatorTest
|
class UrlValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
@ -13,11 +13,12 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Uuid;
|
use Symfony\Component\Validator\Constraints\Uuid;
|
||||||
use Symfony\Component\Validator\Constraints\UuidValidator;
|
use Symfony\Component\Validator\Constraints\UuidValidator;
|
||||||
|
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Colin O'Dell <colinodell@gmail.com>
|
* @author Colin O'Dell <colinodell@gmail.com>
|
||||||
*/
|
*/
|
||||||
class UuidValidatorTest extends AbstractConstraintValidatorTest
|
class UuidValidatorTest extends ConstraintValidatorTestCase
|
||||||
{
|
{
|
||||||
protected function createValidator()
|
protected function createValidator()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user