Ver Fonte

Additional tests for DateTimeValidator, EmailValidator and UrlValidator

stloyd há 14 anos atrás
pai
commit
450ed85aa4

+ 5 - 0
tests/Symfony/Tests/Component/Validator/Constraints/DateTimeValidatorTest.php

@@ -33,6 +33,11 @@ class DateTimeValidatorTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($this->validator->isValid('', new DateTime()));
     }
 
+    public function testDateTimeClassIsValid()
+    {
+        $this->assertTrue($this->validator->isValid(new \DateTime(), new DateTime()));
+    }
+
     public function testExpectsStringCompatibleType()
     {
         $this->setExpectedException('Symfony\Component\Validator\Exception\UnexpectedTypeException');

+ 11 - 0
tests/Symfony/Tests/Component/Validator/Constraints/EmailValidatorTest.php

@@ -48,6 +48,17 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($this->validator->isValid($email, new Email()));
     }
 
+    /**
+     * @dataProvider getValidEmails
+     */
+    public function testValidEmailsAndCheckMX($email)
+    {
+        $validator = new EmailValidator();
+        $validator->checkMX = true;
+
+        $this->assertTrue($validator->isValid($email, new Email()));
+    }
+
     public function getValidEmails()
     {
         return array(

+ 2 - 0
tests/Symfony/Tests/Component/Validator/Constraints/UrlValidatorTest.php

@@ -76,6 +76,8 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase
             array('google.com'),
             array('http:/google.com'),
             array('http://google.com::aa'),
+            array('http://google.foobar'),
+            array('ftp://google.fr'),
         );
     }