Przeglądaj źródła

[Validator] Added tests for AssertTypeValidator

Bernhard Schussek 14 lat temu
rodzic
commit
fea37a3e95

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

@@ -30,6 +30,16 @@ class AssertTypeValidatorTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($this->validator->isValid(null, new AssertType(array('type' => 'integer'))));
     }
 
+    public function testEmptyIsValidIfString()
+    {
+        $this->assertTrue($this->validator->isValid('', new AssertType(array('type' => 'string'))));
+    }
+
+    public function testEmptyIsInvalidIfNoString()
+    {
+        $this->assertFalse($this->validator->isValid('', new AssertType(array('type' => 'integer'))));
+    }
+
     /**
      * @dataProvider getValidValues
      */