[Form] Add test for the handling of array values in the constraint violation
This commit is contained in:
parent
a7ff4f484a
commit
361c67f54f
@ -13,6 +13,7 @@ namespace Symfony\Tests\Component\Validator\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\ConstraintViolation;
|
||||||
|
|
||||||
class TypeValidatorTest extends \PHPUnit_Framework_TestCase
|
class TypeValidatorTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
@ -83,6 +84,22 @@ class TypeValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertFalse($this->validator->isValid($value, $constraint));
|
$this->assertFalse($this->validator->isValid($value, $constraint));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testConstraintViolationCanHandleArrayValue()
|
||||||
|
{
|
||||||
|
$constraint = new Type(array('type' => 'string'));
|
||||||
|
$this->validator->isValid(array(0 => "Test"), $constraint);
|
||||||
|
|
||||||
|
$violation = new ConstraintViolation(
|
||||||
|
'{{ value }}',
|
||||||
|
$this->validator->getMessageParameters(),
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
''
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals('Array', $violation->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
public function getInvalidValues()
|
public function getInvalidValues()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user