X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fvalidator%2FTests%2FConstraints%2FUrlValidatorTest.php;h=13cacb0f3ba56206afd7f2f82e6be0e9a336af17;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=57c00c2b82e4812e2417861e8922f2934cc68192;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/validator/Tests/Constraints/UrlValidatorTest.php b/vendor/symfony/validator/Tests/Constraints/UrlValidatorTest.php index 57c00c2b8..13cacb0f3 100644 --- a/vendor/symfony/validator/Tests/Constraints/UrlValidatorTest.php +++ b/vendor/symfony/validator/Tests/Constraints/UrlValidatorTest.php @@ -14,18 +14,13 @@ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Bridge\PhpUnit\DnsMock; use Symfony\Component\Validator\Constraints\Url; use Symfony\Component\Validator\Constraints\UrlValidator; -use Symfony\Component\Validator\Validation; +use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; /** * @group dns-sensitive */ -class UrlValidatorTest extends AbstractConstraintValidatorTest +class UrlValidatorTest extends ConstraintValidatorTestCase { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new UrlValidator(); @@ -121,6 +116,9 @@ class UrlValidatorTest extends AbstractConstraintValidatorTest array('http://xn--d1abbgf6aiiy.xn--p1ai/'), array('http://☎.com/'), array('http://username:password@symfony.com'), + array('http://user.name:password@symfony.com'), + array('http://username:pass.word@symfony.com'), + array('http://user.name:pass.word@symfony.com'), array('http://user-name@symfony.com'), array('http://symfony.com?'), array('http://symfony.com?query=1'), @@ -172,6 +170,7 @@ class UrlValidatorTest extends AbstractConstraintValidatorTest array('http://example.com/exploit.html?'), array('http://example.com/exploit.html?hel lo'), array('http://example.com/exploit.html?not_a%hex'), + array('http://'), ); } @@ -207,7 +206,7 @@ class UrlValidatorTest extends AbstractConstraintValidatorTest DnsMock::withMockedHosts(array('example.com' => array(array('type' => $violation ? '' : 'A')))); $constraint = new Url(array( - 'checkDNS' => true, + 'checkDNS' => 'ANY', 'dnsMessage' => 'myMessage', )); @@ -227,6 +226,75 @@ class UrlValidatorTest extends AbstractConstraintValidatorTest { return array(array(true), array(false)); } + + /** + * @dataProvider getCheckDnsTypes + * @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts + */ + public function testCheckDnsByType($type) + { + DnsMock::withMockedHosts(array('example.com' => array(array('type' => $type)))); + + $constraint = new Url(array( + 'checkDNS' => $type, + 'dnsMessage' => 'myMessage', + )); + + $this->validator->validate('http://example.com', $constraint); + + $this->assertNoViolation(); + } + + public function getCheckDnsTypes() + { + return array( + array('ANY'), + array('A'), + array('A6'), + array('AAAA'), + array('CNAME'), + array('MX'), + array('NAPTR'), + array('NS'), + array('PTR'), + array('SOA'), + array('SRV'), + array('TXT'), + ); + } + + /** + * @group legacy + */ + public function testCheckDnsWithBoolean() + { + DnsMock::withMockedHosts(array('example.com' => array(array('type' => 'A')))); + + $constraint = new Url(array( + 'checkDNS' => true, + 'dnsMessage' => 'myMessage', + )); + + $this->validator->validate('http://example.com', $constraint); + + $this->assertNoViolation(); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\InvalidOptionsException + * @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts + */ + public function testCheckDnsWithInvalidType() + { + DnsMock::withMockedHosts(array('example.com' => array(array('type' => 'A')))); + + $constraint = new Url(array( + 'checkDNS' => 'BOGUS', + 'dnsMessage' => 'myMessage', + )); + + $this->validator->validate('http://example.com', $constraint); + } } class EmailProvider