Merge branch '2.3' into 2.4
* 2.3: [Form] Removed constructor argument from FormTypeHttpFoundationExtension for forward compatibility with 2.5 [Validator] Simplified testing of violations
This commit is contained in:
commit
efb1237b72
@ -159,7 +159,10 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($entity2, $constraint);
|
$this->validator->validate($entity2, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(), 'property.path.name', 'Foo');
|
$this->buildViolation('myMessage')
|
||||||
|
->atPath('property.path.name')
|
||||||
|
->setInvalidValue('Foo')
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidateCustomErrorPath()
|
public function testValidateCustomErrorPath()
|
||||||
@ -179,7 +182,10 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($entity2, $constraint);
|
$this->validator->validate($entity2, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(), 'property.path.bar', 'Foo');
|
$this->buildViolation('myMessage')
|
||||||
|
->atPath('property.path.bar')
|
||||||
|
->setInvalidValue('Foo')
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidateUniquenessWithNull()
|
public function testValidateUniquenessWithNull()
|
||||||
@ -227,7 +233,10 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($entity2, $constraint);
|
$this->validator->validate($entity2, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(), 'property.path.name', 'Foo');
|
$this->buildViolation('myMessage')
|
||||||
|
->atPath('property.path.name')
|
||||||
|
->setInvalidValue('Foo')
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidateUniquenessUsingCustomRepositoryMethod()
|
public function testValidateUniquenessUsingCustomRepositoryMethod()
|
||||||
@ -321,7 +330,10 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($associated2, $constraint);
|
$this->validator->validate($associated2, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(), 'property.path.single', 1);
|
$this->buildViolation('myMessage')
|
||||||
|
->atPath('property.path.single')
|
||||||
|
->setInvalidValue(1)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssociatedEntityWithNull()
|
public function testAssociatedEntityWithNull()
|
||||||
|
@ -147,11 +147,8 @@
|
|||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- FormTypeHttpFoundationExtension -->
|
<!-- FormTypeHttpFoundationExtension -->
|
||||||
<service id="form.server_params" class="Symfony\Component\Form\Util\ServerParams" public="false"/>
|
|
||||||
|
|
||||||
<service id="form.type_extension.form.http_foundation" class="Symfony\Component\Form\Extension\HttpFoundation\Type\FormTypeHttpFoundationExtension">
|
<service id="form.type_extension.form.http_foundation" class="Symfony\Component\Form\Extension\HttpFoundation\Type\FormTypeHttpFoundationExtension">
|
||||||
<tag name="form.type_extension" alias="form" />
|
<tag name="form.type_extension" alias="form" />
|
||||||
<argument type="service" id="form.server_params"/>
|
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- FormTypeValidatorExtension -->
|
<!-- FormTypeValidatorExtension -->
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
namespace Symfony\Component\Form\Extension\HttpFoundation;
|
namespace Symfony\Component\Form\Extension\HttpFoundation;
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractExtension;
|
use Symfony\Component\Form\AbstractExtension;
|
||||||
use Symfony\Component\Form\Util\ServerParams;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integrates the HttpFoundation component with the Form library.
|
* Integrates the HttpFoundation component with the Form library.
|
||||||
@ -21,20 +20,10 @@ use Symfony\Component\Form\Util\ServerParams;
|
|||||||
*/
|
*/
|
||||||
class HttpFoundationExtension extends AbstractExtension
|
class HttpFoundationExtension extends AbstractExtension
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var ServerParams
|
|
||||||
*/
|
|
||||||
private $serverParams;
|
|
||||||
|
|
||||||
public function __construct(ServerParams $serverParams = null)
|
|
||||||
{
|
|
||||||
$this->serverParams = $serverParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function loadTypeExtensions()
|
protected function loadTypeExtensions()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
new Type\FormTypeHttpFoundationExtension($this->serverParams),
|
new Type\FormTypeHttpFoundationExtension(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ use Symfony\Component\Form\AbstractTypeExtension;
|
|||||||
use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener;
|
use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener;
|
||||||
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
|
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Form\Util\ServerParams;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
@ -32,10 +31,10 @@ class FormTypeHttpFoundationExtension extends AbstractTypeExtension
|
|||||||
*/
|
*/
|
||||||
private $requestHandler;
|
private $requestHandler;
|
||||||
|
|
||||||
public function __construct(ServerParams $serverParams = null)
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->listener = new BindRequestListener();
|
$this->listener = new BindRequestListener();
|
||||||
$this->requestHandler = new HttpFoundationRequestHandler($serverParams);
|
$this->requestHandler = new HttpFoundationRequestHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -219,10 +219,12 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($form, new Form());
|
$this->validator->validate($form, new Form());
|
||||||
|
|
||||||
$this->assertViolation('invalid_message_key', array(
|
$this->buildViolation('invalid_message_key')
|
||||||
'{{ value }}' => 'foo',
|
->setParameter('{{ value }}', 'foo')
|
||||||
'{{ foo }}' => 'bar',
|
->setParameter('{{ foo }}', 'bar')
|
||||||
), 'property.path', 'foo', null, Form::ERR_INVALID);
|
->setInvalidValue('foo')
|
||||||
|
->setCode(Form::ERR_INVALID)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddInvalidErrorEvenIfNoValidationGroups()
|
public function testAddInvalidErrorEvenIfNoValidationGroups()
|
||||||
@ -251,10 +253,12 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($form, new Form());
|
$this->validator->validate($form, new Form());
|
||||||
|
|
||||||
$this->assertViolation('invalid_message_key', array(
|
$this->buildViolation('invalid_message_key')
|
||||||
'{{ value }}' => 'foo',
|
->setParameter('{{ value }}', 'foo')
|
||||||
'{{ foo }}' => 'bar',
|
->setParameter('{{ foo }}', 'bar')
|
||||||
), 'property.path', 'foo', null, Form::ERR_INVALID);
|
->setInvalidValue('foo')
|
||||||
|
->setCode(Form::ERR_INVALID)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDontValidateConstraintsIfNotSynchronized()
|
public function testDontValidateConstraintsIfNotSynchronized()
|
||||||
@ -283,9 +287,11 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($form, new Form());
|
$this->validator->validate($form, new Form());
|
||||||
|
|
||||||
$this->assertViolation('invalid_message_key', array(
|
$this->buildViolation('invalid_message_key')
|
||||||
'{{ value }}' => 'foo',
|
->setParameter('{{ value }}', 'foo')
|
||||||
), 'property.path','foo', null, Form::ERR_INVALID);
|
->setInvalidValue('foo')
|
||||||
|
->setCode(Form::ERR_INVALID)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/symfony/symfony/issues/4359
|
// https://github.com/symfony/symfony/issues/4359
|
||||||
@ -537,9 +543,10 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($form, new Form());
|
$this->validator->validate($form, new Form());
|
||||||
|
|
||||||
$this->assertViolation('Extra!', array(
|
$this->buildViolation('Extra!')
|
||||||
'{{ extra_fields }}' => 'foo',
|
->setParameter('{{ extra_fields }}', 'foo')
|
||||||
), 'property.path', array('foo' => 'bar'));
|
->setInvalidValue(array('foo' => 'bar'))
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,11 +84,11 @@ abstract class AbstractComparisonValidatorTestCase extends AbstractConstraintVal
|
|||||||
|
|
||||||
$this->validator->validate($dirtyValue, $constraint);
|
$this->validator->validate($dirtyValue, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('Constraint Message', array(
|
$this->buildViolation('Constraint Message')
|
||||||
'{{ value }}' => $dirtyValueAsString,
|
->setParameter('{{ value }}', $dirtyValueAsString)
|
||||||
'{{ compared_value }}' => $comparedValueString,
|
->setParameter('{{ compared_value }}', $comparedValueString)
|
||||||
'{{ compared_value_type }}' => $comparedValueType,
|
->setParameter('{{ compared_value_type }}', $comparedValueType)
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,8 +13,7 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\ConstraintValidatorInterface;
|
use Symfony\Component\Validator\ConstraintValidatorInterface;
|
||||||
use Symfony\Component\Validator\ConstraintViolation;
|
use Symfony\Component\Validator\ConstraintViolation;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContext;
|
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|
||||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
use Symfony\Component\Validator\Mapping\PropertyMetadata;
|
use Symfony\Component\Validator\Mapping\PropertyMetadata;
|
||||||
use Symfony\Component\Validator\Tests\Fixtures\StubGlobalExecutionContext;
|
use Symfony\Component\Validator\Tests\Fixtures\StubGlobalExecutionContext;
|
||||||
@ -80,6 +79,19 @@ abstract class AbstractConstraintValidatorTest extends \PHPUnit_Framework_TestCa
|
|||||||
->getMock();
|
->getMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $message
|
||||||
|
* @param array $parameters
|
||||||
|
* @param string $propertyPath
|
||||||
|
* @param string $invalidValue
|
||||||
|
* @param null $plural
|
||||||
|
* @param null $code
|
||||||
|
*
|
||||||
|
* @return ConstraintViolation
|
||||||
|
*
|
||||||
|
* @deprecated To be removed in Symfony 3.0. Use
|
||||||
|
* {@link buildViolation()} instead.
|
||||||
|
*/
|
||||||
protected function createViolation($message, array $parameters = array(), $propertyPath = 'property.path', $invalidValue = 'InvalidValue', $plural = null, $code = null)
|
protected function createViolation($message, array $parameters = array(), $propertyPath = 'property.path', $invalidValue = 'InvalidValue', $plural = null, $code = null)
|
||||||
{
|
{
|
||||||
return new ConstraintViolation(
|
return new ConstraintViolation(
|
||||||
@ -169,14 +181,34 @@ abstract class AbstractConstraintValidatorTest extends \PHPUnit_Framework_TestCa
|
|||||||
$this->assertCount(0, $this->context->getViolations());
|
$this->assertCount(0, $this->context->getViolations());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $message
|
||||||
|
* @param array $parameters
|
||||||
|
* @param string $propertyPath
|
||||||
|
* @param string $invalidValue
|
||||||
|
* @param null $plural
|
||||||
|
* @param null $code
|
||||||
|
*
|
||||||
|
* @deprecated To be removed in Symfony 3.0. Use
|
||||||
|
* {@link buildViolation()} instead.
|
||||||
|
*/
|
||||||
protected function assertViolation($message, array $parameters = array(), $propertyPath = 'property.path', $invalidValue = 'InvalidValue', $plural = null, $code = null)
|
protected function assertViolation($message, array $parameters = array(), $propertyPath = 'property.path', $invalidValue = 'InvalidValue', $plural = null, $code = null)
|
||||||
{
|
{
|
||||||
$violations = $this->context->getViolations();
|
$this->buildViolation($message)
|
||||||
|
->setParameters($parameters)
|
||||||
$this->assertCount(1, $violations);
|
->atPath($propertyPath)
|
||||||
$this->assertEquals($this->createViolation($message, $parameters, $propertyPath, $invalidValue, $plural, $code), $violations[0]);
|
->setInvalidValue($invalidValue)
|
||||||
|
->setCode($code)
|
||||||
|
->setPlural($plural)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $expected
|
||||||
|
*
|
||||||
|
* @deprecated To be removed in Symfony 3.0. Use
|
||||||
|
* {@link buildViolation()} instead.
|
||||||
|
*/
|
||||||
protected function assertViolations(array $expected)
|
protected function assertViolations(array $expected)
|
||||||
{
|
{
|
||||||
$violations = $this->context->getViolations();
|
$violations = $this->context->getViolations();
|
||||||
@ -190,5 +222,137 @@ abstract class AbstractConstraintValidatorTest extends \PHPUnit_Framework_TestCa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $message
|
||||||
|
*
|
||||||
|
* @return ConstraintViolationAssertion
|
||||||
|
*/
|
||||||
|
protected function buildViolation($message)
|
||||||
|
{
|
||||||
|
return new ConstraintViolationAssertion($this->context, $message);
|
||||||
|
}
|
||||||
|
|
||||||
abstract protected function createValidator();
|
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;
|
||||||
|
|
||||||
|
public function __construct(ExecutionContextInterface $context, $message, array $assertions = array())
|
||||||
|
{
|
||||||
|
$this->context = $context;
|
||||||
|
$this->message = $message;
|
||||||
|
$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 buildNextViolation($message)
|
||||||
|
{
|
||||||
|
$assertions = $this->assertions;
|
||||||
|
$assertions[] = $this;
|
||||||
|
|
||||||
|
return new self($this->context, $message, $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::assertCount(count($expected), $violations);
|
||||||
|
|
||||||
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -46,10 +46,9 @@ class BlankValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation(
|
$this->buildViolation('myMessage')
|
||||||
'myMessage',
|
->setParameter('{{ value }}', $valueAsString)
|
||||||
array('{{ value }}' => $valueAsString)
|
->assertRaised();
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidValues()
|
public function getInvalidValues()
|
||||||
|
@ -64,9 +64,9 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
$this->validator->validate($object, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('My message', array(
|
$this->buildViolation('My message')
|
||||||
'{{ value }}' => 'foobar',
|
->setParameter('{{ value }}', 'foobar')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSingleMethodExplicitName()
|
public function testSingleMethodExplicitName()
|
||||||
@ -174,9 +174,9 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
$this->validator->validate($object, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('My message', array(
|
$this->buildViolation('My message')
|
||||||
'{{ value }}' => 'foobar',
|
->setParameter('{{ value }}', 'foobar')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
// BC with Symfony < 2.4
|
// BC with Symfony < 2.4
|
||||||
@ -187,14 +187,11 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
$this->validator->validate($object, $constraint);
|
||||||
|
|
||||||
$this->assertViolations(array(
|
$this->buildViolation('My message')
|
||||||
$this->createViolation('My message', array(
|
->setParameter('{{ value }}', 'foobar')
|
||||||
'{{ value }}' => 'foobar',
|
->buildNextViolation('Static message')
|
||||||
)),
|
->setParameter('{{ value }}', 'baz')
|
||||||
$this->createViolation('Static message', array(
|
->assertRaised();
|
||||||
'{{ value }}' => 'baz',
|
|
||||||
)),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BC with Symfony < 2.4
|
// BC with Symfony < 2.4
|
||||||
@ -207,14 +204,11 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
$this->validator->validate($object, $constraint);
|
||||||
|
|
||||||
$this->assertViolations(array(
|
$this->buildViolation('My message')
|
||||||
$this->createViolation('My message', array(
|
->setParameter('{{ value }}', 'foobar')
|
||||||
'{{ value }}' => 'foobar',
|
->buildNextViolation('Static message')
|
||||||
)),
|
->setParameter('{{ value }}', 'baz')
|
||||||
$this->createViolation('Static message', array(
|
->assertRaised();
|
||||||
'{{ value }}' => 'baz',
|
|
||||||
)),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BC with Symfony < 2.4
|
// BC with Symfony < 2.4
|
||||||
@ -227,9 +221,9 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
$this->validator->validate($object, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('Callback message', array(
|
$this->buildViolation('Callback message')
|
||||||
'{{ value }}' => 'foobar',
|
->setParameter('{{ value }}', 'foobar')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
// BC with Symfony < 2.4
|
// BC with Symfony < 2.4
|
||||||
@ -242,9 +236,9 @@ class CallbackValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($object, $constraint);
|
$this->validator->validate($object, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('Callback message', array(
|
$this->buildViolation('Callback message')
|
||||||
'{{ value }}' => 'foobar',
|
->setParameter('{{ value }}', 'foobar')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,9 +57,9 @@ class CardSchemeValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($number, $constraint);
|
$this->validator->validate($number, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => is_string($number) ? '"'.$number.'"' : $number,
|
->setParameter('{{ value }}', is_string($number) ? '"'.$number.'"' : $number)
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidNumbers()
|
public function getValidNumbers()
|
||||||
|
@ -138,9 +138,9 @@ class ChoiceValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate('baz', $constraint);
|
$this->validator->validate('baz', $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"baz"',
|
->setParameter('{{ value }}', '"baz"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidChoiceMultiple()
|
public function testInvalidChoiceMultiple()
|
||||||
@ -153,9 +153,9 @@ class ChoiceValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate(array('foo', 'baz'), $constraint);
|
$this->validator->validate(array('foo', 'baz'), $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"baz"',
|
->setParameter('{{ value }}', '"baz"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTooFewChoices()
|
public function testTooFewChoices()
|
||||||
@ -173,9 +173,11 @@ class ChoiceValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ limit }}' => 2,
|
->setParameter('{{ limit }}', 2)
|
||||||
), 'property.path', $value, 2);
|
->setInvalidValue($value)
|
||||||
|
->setPlural(2)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTooManyChoices()
|
public function testTooManyChoices()
|
||||||
@ -193,9 +195,11 @@ class ChoiceValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ limit }}' => 2,
|
->setParameter('{{ limit }}', 2)
|
||||||
), 'property.path', $value, 2);
|
->setInvalidValue($value)
|
||||||
|
->setPlural(2)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNonStrict()
|
public function testNonStrict()
|
||||||
@ -233,9 +237,9 @@ class ChoiceValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate('2', $constraint);
|
$this->validator->validate('2', $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"2"',
|
->setParameter('{{ value }}', '"2"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNonStrictWithMultipleChoices()
|
public function testNonStrictWithMultipleChoices()
|
||||||
@ -262,8 +266,8 @@ class ChoiceValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate(array(2, '3'), $constraint);
|
$this->validator->validate(array(2, '3'), $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"3"',
|
->setParameter('{{ value }}', '"3"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,9 +136,11 @@ abstract class CollectionValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
'extraFieldsMessage' => 'myMessage',
|
'extraFieldsMessage' => 'myMessage',
|
||||||
)));
|
)));
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ field }}' => '"baz"',
|
->setParameter('{{ field }}', '"baz"')
|
||||||
), 'property.path[baz]', 6);
|
->atPath('property.path[baz]')
|
||||||
|
->setInvalidValue(6)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
// bug fix
|
// bug fix
|
||||||
@ -195,9 +197,11 @@ abstract class CollectionValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
'missingFieldsMessage' => 'myMessage',
|
'missingFieldsMessage' => 'myMessage',
|
||||||
)));
|
)));
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ field }}' => '"foo"',
|
->setParameter('{{ field }}', '"foo"')
|
||||||
), 'property.path[foo]', null);
|
->atPath('property.path[foo]')
|
||||||
|
->setInvalidValue(null)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMissingFieldsAllowed()
|
public function testMissingFieldsAllowed()
|
||||||
@ -305,9 +309,11 @@ abstract class CollectionValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
'missingFieldsMessage' => 'myMessage',
|
'missingFieldsMessage' => 'myMessage',
|
||||||
)));
|
)));
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ field }}' => '"foo"',
|
->setParameter('{{ field }}', '"foo"')
|
||||||
), 'property.path[foo]', null);
|
->atPath('property.path[foo]')
|
||||||
|
->setInvalidValue(null)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRequiredFieldSingleConstraint()
|
public function testRequiredFieldSingleConstraint()
|
||||||
|
@ -121,10 +121,12 @@ abstract class CountValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ count }}' => count($value),
|
->setParameter('{{ count }}', count($value))
|
||||||
'{{ limit }}' => 4,
|
->setParameter('{{ limit }}', 4)
|
||||||
), 'property.path', $value, 4);
|
->setInvalidValue($value)
|
||||||
|
->setPlural(4)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,10 +141,12 @@ abstract class CountValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ count }}' => count($value),
|
->setParameter('{{ count }}', count($value))
|
||||||
'{{ limit }}' => 4,
|
->setParameter('{{ limit }}', 4)
|
||||||
), 'property.path', $value, 4);
|
->setInvalidValue($value)
|
||||||
|
->setPlural(4)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,10 +162,12 @@ abstract class CountValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ count }}' => count($value),
|
->setParameter('{{ count }}', count($value))
|
||||||
'{{ limit }}' => 4,
|
->setParameter('{{ limit }}', 4)
|
||||||
), 'property.path', $value, 4);
|
->setInvalidValue($value)
|
||||||
|
->setPlural(4)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultOption()
|
public function testDefaultOption()
|
||||||
|
@ -81,9 +81,9 @@ class CountryValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($country, $constraint);
|
$this->validator->validate($country, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$country.'"',
|
->setParameter('{{ value }}', '"'.$country.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidCountries()
|
public function getInvalidCountries()
|
||||||
|
@ -95,9 +95,9 @@ class CurrencyValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($currency, $constraint);
|
$this->validator->validate($currency, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$currency.'"',
|
->setParameter('{{ value }}', '"'.$currency.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidCurrencies()
|
public function getInvalidCurrencies()
|
||||||
|
@ -80,9 +80,9 @@ class DateTimeValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($dateTime, $constraint);
|
$this->validator->validate($dateTime, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$dateTime.'"',
|
->setParameter('{{ value }}', '"'.$dateTime.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidDateTimes()
|
public function getInvalidDateTimes()
|
||||||
|
@ -80,9 +80,9 @@ class DateValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($date, $constraint);
|
$this->validator->validate($date, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$date.'"',
|
->setParameter('{{ value }}', '"'.$date.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidDates()
|
public function getInvalidDates()
|
||||||
|
@ -73,9 +73,9 @@ class EmailValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($email, $constraint);
|
$this->validator->validate($email, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$email.'"',
|
->setParameter('{{ value }}', '"'.$email.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidEmails()
|
public function getInvalidEmails()
|
||||||
|
@ -43,8 +43,8 @@ class FalseValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate(true, $constraint);
|
$this->validator->validate(true, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => 'true',
|
->setParameter('{{ value }}', 'true')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ class FileValidatorPathTest extends FileValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate('foobar', $constraint);
|
$this->validator->validate('foobar', $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ file }}' => '"foobar"',
|
->setParameter('{{ file }}', '"foobar"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,12 +162,12 @@ abstract class FileValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($this->getFile($this->path), $constraint);
|
$this->validator->validate($this->getFile($this->path), $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ limit }}' => $limitAsString,
|
->setParameter('{{ limit }}', $limitAsString)
|
||||||
'{{ size }}' => $sizeAsString,
|
->setParameter('{{ size }}', $sizeAsString)
|
||||||
'{{ suffix }}' => $suffix,
|
->setParameter('{{ suffix }}', $suffix)
|
||||||
'{{ file }}' => '"'.$this->path.'"',
|
->setParameter('{{ file }}', '"'.$this->path.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function provideMaxSizeNotExceededTests()
|
public function provideMaxSizeNotExceededTests()
|
||||||
@ -231,18 +231,15 @@ abstract class FileValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
$file = $this
|
$file = $this
|
||||||
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
||||||
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
||||||
->getMock()
|
->getMock();
|
||||||
;
|
|
||||||
$file
|
$file
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getPathname')
|
->method('getPathname')
|
||||||
->will($this->returnValue($this->path))
|
->will($this->returnValue($this->path));
|
||||||
;
|
|
||||||
$file
|
$file
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getMimeType')
|
->method('getMimeType')
|
||||||
->will($this->returnValue('image/jpg'))
|
->will($this->returnValue('image/jpg'));
|
||||||
;
|
|
||||||
|
|
||||||
$constraint = new File(array(
|
$constraint = new File(array(
|
||||||
'mimeTypes' => array('image/png', 'image/jpg'),
|
'mimeTypes' => array('image/png', 'image/jpg'),
|
||||||
@ -258,18 +255,15 @@ abstract class FileValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
$file = $this
|
$file = $this
|
||||||
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
||||||
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
||||||
->getMock()
|
->getMock();
|
||||||
;
|
|
||||||
$file
|
$file
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getPathname')
|
->method('getPathname')
|
||||||
->will($this->returnValue($this->path))
|
->will($this->returnValue($this->path));
|
||||||
;
|
|
||||||
$file
|
$file
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getMimeType')
|
->method('getMimeType')
|
||||||
->will($this->returnValue('image/jpg'))
|
->will($this->returnValue('image/jpg'));
|
||||||
;
|
|
||||||
|
|
||||||
$constraint = new File(array(
|
$constraint = new File(array(
|
||||||
'mimeTypes' => array('image/*'),
|
'mimeTypes' => array('image/*'),
|
||||||
@ -285,18 +279,15 @@ abstract class FileValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
$file = $this
|
$file = $this
|
||||||
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
||||||
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
||||||
->getMock()
|
->getMock();
|
||||||
;
|
|
||||||
$file
|
$file
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getPathname')
|
->method('getPathname')
|
||||||
->will($this->returnValue($this->path))
|
->will($this->returnValue($this->path));
|
||||||
;
|
|
||||||
$file
|
$file
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getMimeType')
|
->method('getMimeType')
|
||||||
->will($this->returnValue('application/pdf'))
|
->will($this->returnValue('application/pdf'));
|
||||||
;
|
|
||||||
|
|
||||||
$constraint = new File(array(
|
$constraint = new File(array(
|
||||||
'mimeTypes' => array('image/png', 'image/jpg'),
|
'mimeTypes' => array('image/png', 'image/jpg'),
|
||||||
@ -305,11 +296,11 @@ abstract class FileValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($file, $constraint);
|
$this->validator->validate($file, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ type }}' => '"application/pdf"',
|
->setParameter('{{ type }}', '"application/pdf"')
|
||||||
'{{ types }}' => '"image/png", "image/jpg"',
|
->setParameter('{{ types }}', '"image/png", "image/jpg"')
|
||||||
'{{ file }}' => '"'.$this->path.'"',
|
->setParameter('{{ file }}', '"'.$this->path.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidWildcardMimeType()
|
public function testInvalidWildcardMimeType()
|
||||||
@ -317,18 +308,15 @@ abstract class FileValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
$file = $this
|
$file = $this
|
||||||
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
||||||
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
||||||
->getMock()
|
->getMock();
|
||||||
;
|
|
||||||
$file
|
$file
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getPathname')
|
->method('getPathname')
|
||||||
->will($this->returnValue($this->path))
|
->will($this->returnValue($this->path));
|
||||||
;
|
|
||||||
$file
|
$file
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getMimeType')
|
->method('getMimeType')
|
||||||
->will($this->returnValue('application/pdf'))
|
->will($this->returnValue('application/pdf'));
|
||||||
;
|
|
||||||
|
|
||||||
$constraint = new File(array(
|
$constraint = new File(array(
|
||||||
'mimeTypes' => array('image/*', 'image/jpg'),
|
'mimeTypes' => array('image/*', 'image/jpg'),
|
||||||
@ -337,11 +325,11 @@ abstract class FileValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($file, $constraint);
|
$this->validator->validate($file, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ type }}' => '"application/pdf"',
|
->setParameter('{{ type }}', '"application/pdf"')
|
||||||
'{{ types }}' => '"image/*", "image/jpg"',
|
->setParameter('{{ types }}', '"image/*", "image/jpg"')
|
||||||
'{{ file }}' => '"'.$this->path.'"',
|
->setParameter('{{ file }}', '"'.$this->path.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -358,7 +346,9 @@ abstract class FileValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($file, $constraint);
|
$this->validator->validate($file, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', $params);
|
$this->buildViolation('myMessage')
|
||||||
|
->setParameters($params)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uploadedFileErrorProvider()
|
public function uploadedFileErrorProvider()
|
||||||
|
@ -158,9 +158,9 @@ class IbanValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($iban, $constraint);
|
$this->validator->validate($iban, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$iban.'"',
|
->setParameter('{{ value }}', '"'.$iban.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidIbans()
|
public function getInvalidIbans()
|
||||||
|
@ -88,10 +88,10 @@ class ImageValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($this->image, $constraint);
|
$this->validator->validate($this->image, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ width }}' => '2',
|
->setParameter('{{ width }}', '2')
|
||||||
'{{ min_width }}' => '3',
|
->setParameter('{{ min_width }}', '3')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWidthTooBig()
|
public function testWidthTooBig()
|
||||||
@ -103,10 +103,10 @@ class ImageValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($this->image, $constraint);
|
$this->validator->validate($this->image, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ width }}' => '2',
|
->setParameter('{{ width }}', '2')
|
||||||
'{{ max_width }}' => '1',
|
->setParameter('{{ max_width }}', '1')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHeightTooSmall()
|
public function testHeightTooSmall()
|
||||||
@ -118,10 +118,10 @@ class ImageValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($this->image, $constraint);
|
$this->validator->validate($this->image, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ height }}' => '2',
|
->setParameter('{{ height }}', '2')
|
||||||
'{{ min_height }}' => '3',
|
->setParameter('{{ min_height }}', '3')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHeightTooBig()
|
public function testHeightTooBig()
|
||||||
@ -133,10 +133,10 @@ class ImageValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($this->image, $constraint);
|
$this->validator->validate($this->image, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ height }}' => '2',
|
->setParameter('{{ height }}', '2')
|
||||||
'{{ max_height }}' => '1',
|
->setParameter('{{ max_height }}', '1')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -145,9 +145,9 @@ class IpValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
$this->validator->validate($ip, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$ip.'"',
|
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidIpsV4()
|
public function getInvalidIpsV4()
|
||||||
@ -177,9 +177,9 @@ class IpValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
$this->validator->validate($ip, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$ip.'"',
|
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidPrivateIpsV4()
|
public function getInvalidPrivateIpsV4()
|
||||||
@ -203,9 +203,9 @@ class IpValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
$this->validator->validate($ip, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$ip.'"',
|
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidReservedIpsV4()
|
public function getInvalidReservedIpsV4()
|
||||||
@ -229,9 +229,9 @@ class IpValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
$this->validator->validate($ip, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$ip.'"',
|
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidPublicIpsV4()
|
public function getInvalidPublicIpsV4()
|
||||||
@ -251,9 +251,9 @@ class IpValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
$this->validator->validate($ip, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$ip.'"',
|
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidIpsV6()
|
public function getInvalidIpsV6()
|
||||||
@ -287,9 +287,9 @@ class IpValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
$this->validator->validate($ip, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$ip.'"',
|
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidPrivateIpsV6()
|
public function getInvalidPrivateIpsV6()
|
||||||
@ -313,9 +313,9 @@ class IpValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
$this->validator->validate($ip, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$ip.'"',
|
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidReservedIpsV6()
|
public function getInvalidReservedIpsV6()
|
||||||
@ -338,9 +338,9 @@ class IpValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
$this->validator->validate($ip, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$ip.'"',
|
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidPublicIpsV6()
|
public function getInvalidPublicIpsV6()
|
||||||
@ -360,9 +360,9 @@ class IpValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
$this->validator->validate($ip, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$ip.'"',
|
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidIpsAll()
|
public function getInvalidIpsAll()
|
||||||
@ -382,9 +382,9 @@ class IpValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
$this->validator->validate($ip, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$ip.'"',
|
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidPrivateIpsAll()
|
public function getInvalidPrivateIpsAll()
|
||||||
@ -404,9 +404,9 @@ class IpValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
$this->validator->validate($ip, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$ip.'"',
|
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidReservedIpsAll()
|
public function getInvalidReservedIpsAll()
|
||||||
@ -426,9 +426,9 @@ class IpValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($ip, $constraint);
|
$this->validator->validate($ip, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$ip.'"',
|
->setParameter('{{ value }}', '"'.$ip.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidPublicIpsAll()
|
public function getInvalidPublicIpsAll()
|
||||||
|
@ -170,9 +170,9 @@ class IsbnValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($isbn, $constraint);
|
$this->validator->validate($isbn, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$isbn.'"',
|
->setParameter('{{ value }}', '"'.$isbn.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,9 +199,9 @@ class IsbnValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($isbn, $constraint);
|
$this->validator->validate($isbn, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$isbn.'"',
|
->setParameter('{{ value }}', '"'.$isbn.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -232,8 +232,8 @@ class IsbnValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($isbn, $constraint);
|
$this->validator->validate($isbn, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$isbn.'"',
|
->setParameter('{{ value }}', '"'.$isbn.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,9 +140,9 @@ class IssnValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$issn.'"',
|
->setParameter('{{ value }}', '"'.$issn.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,9 +157,9 @@ class IssnValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$issn.'"',
|
->setParameter('{{ value }}', '"'.$issn.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -185,9 +185,9 @@ class IssnValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$issn.'"',
|
->setParameter('{{ value }}', '"'.$issn.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -201,9 +201,9 @@ class IssnValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$issn.'"',
|
->setParameter('{{ value }}', '"'.$issn.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -217,8 +217,8 @@ class IssnValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($issn, $constraint);
|
$this->validator->validate($issn, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$issn.'"',
|
->setParameter('{{ value }}', '"'.$issn.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,9 +81,9 @@ class LanguageValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($language, $constraint);
|
$this->validator->validate($language, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$language.'"',
|
->setParameter('{{ value }}', '"'.$language.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidLanguages()
|
public function getInvalidLanguages()
|
||||||
|
@ -150,10 +150,12 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$value.'"',
|
->setParameter('{{ value }}', '"'.$value.'"')
|
||||||
'{{ limit }}' => 4,
|
->setParameter('{{ limit }}', 4)
|
||||||
), 'property.path', $value, 4);
|
->setInvalidValue($value)
|
||||||
|
->setPlural(4)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -172,10 +174,12 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$value.'"',
|
->setParameter('{{ value }}', '"'.$value.'"')
|
||||||
'{{ limit }}' => 4,
|
->setParameter('{{ limit }}', 4)
|
||||||
), 'property.path', $value, 4);
|
->setInvalidValue($value)
|
||||||
|
->setPlural(4)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -195,10 +199,12 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$value.'"',
|
->setParameter('{{ value }}', '"'.$value.'"')
|
||||||
'{{ limit }}' => 4,
|
->setParameter('{{ limit }}', 4)
|
||||||
), 'property.path', $value, 4);
|
->setInvalidValue($value)
|
||||||
|
->setPlural(4)
|
||||||
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConstraintGetDefaultOption()
|
public function testConstraintGetDefaultOption()
|
||||||
|
@ -83,9 +83,9 @@ class LocaleValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($locale, $constraint);
|
$this->validator->validate($locale, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$locale.'"',
|
->setParameter('{{ value }}', '"'.$locale.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidLocales()
|
public function getInvalidLocales()
|
||||||
|
@ -80,9 +80,9 @@ class LuhnValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($number, $constraint);
|
$this->validator->validate($number, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$number.'"',
|
->setParameter('{{ value }}', '"'.$number.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidNumbers()
|
public function getInvalidNumbers()
|
||||||
|
@ -50,9 +50,9 @@ class NotBlankValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate(null, $constraint);
|
$this->validator->validate(null, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => 'null',
|
->setParameter('{{ value }}', 'null')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBlankIsInvalid()
|
public function testBlankIsInvalid()
|
||||||
@ -63,9 +63,9 @@ class NotBlankValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate('', $constraint);
|
$this->validator->validate('', $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '""',
|
->setParameter('{{ value }}', '""')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFalseIsInvalid()
|
public function testFalseIsInvalid()
|
||||||
@ -76,9 +76,9 @@ class NotBlankValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate(false, $constraint);
|
$this->validator->validate(false, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => 'false',
|
->setParameter('{{ value }}', 'false')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmptyArrayIsInvalid()
|
public function testEmptyArrayIsInvalid()
|
||||||
@ -89,8 +89,8 @@ class NotBlankValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate(array(), $constraint);
|
$this->validator->validate(array(), $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => 'array',
|
->setParameter('{{ value }}', 'array')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,6 @@ class NotNullValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate(null, $constraint);
|
$this->validator->validate(null, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage');
|
$this->buildViolation('myMessage')->assertRaised();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,9 @@ class NullValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => $valueAsString,
|
->setParameter('{{ value }}', $valueAsString)
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidValues()
|
public function getInvalidValues()
|
||||||
|
@ -107,10 +107,10 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => $value,
|
->setParameter('{{ value }}', $value)
|
||||||
'{{ limit }}' => 10,
|
->setParameter('{{ limit }}', 10)
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,10 +125,10 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => $value,
|
->setParameter('{{ value }}', $value)
|
||||||
'{{ limit }}' => 20,
|
->setParameter('{{ limit }}', 20)
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,10 +145,10 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMaxMessage', array(
|
$this->buildViolation('myMaxMessage')
|
||||||
'{{ value }}' => $value,
|
->setParameter('{{ value }}', $value)
|
||||||
'{{ limit }}' => 20,
|
->setParameter('{{ limit }}', 20)
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -165,10 +165,10 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMinMessage', array(
|
$this->buildViolation('myMinMessage')
|
||||||
'{{ value }}' => $value,
|
->setParameter('{{ value }}', $value)
|
||||||
'{{ limit }}' => 10,
|
->setParameter('{{ limit }}', 10)
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidValues()
|
public function getInvalidValues()
|
||||||
@ -192,10 +192,10 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate(9, $constraint);
|
$this->validator->validate(9, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => 9,
|
->setParameter('{{ value }}', 9)
|
||||||
'{{ limit }}' => 10,
|
->setParameter('{{ limit }}', 10)
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMaxMessageIsSet()
|
public function testMaxMessageIsSet()
|
||||||
@ -208,10 +208,10 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate(21, $constraint);
|
$this->validator->validate(21, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => 21,
|
->setParameter('{{ value }}', 21)
|
||||||
'{{ limit }}' => 20,
|
->setParameter('{{ limit }}', 20)
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNonNumeric()
|
public function testNonNumeric()
|
||||||
@ -222,8 +222,8 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
'invalidMessage' => 'myMessage',
|
'invalidMessage' => 'myMessage',
|
||||||
)));
|
)));
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"abcd"',
|
->setParameter('{{ value }}', '"abcd"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,9 +76,9 @@ class RegexValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$value.'"',
|
->setParameter('{{ value }}', '"'.$value.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidValues()
|
public function getInvalidValues()
|
||||||
|
@ -80,9 +80,9 @@ class TimeValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($time, $constraint);
|
$this->validator->validate($time, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$time.'"',
|
->setParameter('{{ value }}', '"'.$time.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidTimes()
|
public function getInvalidTimes()
|
||||||
|
@ -43,8 +43,8 @@ class TrueValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate(false, $constraint);
|
$this->validator->validate(false, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => 'false',
|
->setParameter('{{ value }}', 'false')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,10 @@ class TypeValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate('', $constraint);
|
$this->validator->validate('', $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '""',
|
->setParameter('{{ value }}', '""')
|
||||||
'{{ type }}' => 'integer',
|
->setParameter('{{ type }}', 'integer')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -117,10 +117,10 @@ class TypeValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($value, $constraint);
|
$this->validator->validate($value, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => $valueAsString,
|
->setParameter('{{ value }}', $valueAsString)
|
||||||
'{{ type }}' => $type,
|
->setParameter('{{ type }}', $type)
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidValues()
|
public function getInvalidValues()
|
||||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Validator\Tests\Constraints;
|
|||||||
|
|
||||||
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\Validation;
|
|
||||||
|
|
||||||
class UrlValidatorTest extends AbstractConstraintValidatorTest
|
class UrlValidatorTest extends AbstractConstraintValidatorTest
|
||||||
{
|
{
|
||||||
@ -119,9 +118,9 @@ class UrlValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
|
|
||||||
$this->validator->validate($url, $constraint);
|
$this->validator->validate($url, $constraint);
|
||||||
|
|
||||||
$this->assertViolation('myMessage', array(
|
$this->buildViolation('myMessage')
|
||||||
'{{ value }}' => '"'.$url.'"',
|
->setParameter('{{ value }}', '"'.$url.'"')
|
||||||
));
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvalidUrls()
|
public function getInvalidUrls()
|
||||||
|
Reference in New Issue
Block a user