[Form] Add test for the handling of array values in the constraint violation

This commit is contained in:
Dirk Pahl 2011-05-16 15:05:52 +02:00 committed by Bernhard Schussek
parent a7ff4f484a
commit 361c67f54f

View File

@ -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()
{ {