浏览代码

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

Dirk Pahl 14 年之前
父节点
当前提交
361c67f54f
共有 1 个文件被更改,包括 17 次插入0 次删除
  1. 17 0
      tests/Symfony/Tests/Component/Validator/Constraints/AssertTypeValidatorTest.php

+ 17 - 0
tests/Symfony/Tests/Component/Validator/Constraints/AssertTypeValidatorTest.php

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