File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
src/Symfony/Component/Validator/Tests/Constraints Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1111
1212namespace Symfony \Component \Validator \Tests \Constraints ;
1313
14+ use Symfony \Bridge \PhpUnit \DnsMock ;
1415use Symfony \Component \Validator \Constraints \Url ;
1516use Symfony \Component \Validator \Constraints \UrlValidator ;
1617use Symfony \Component \Validator \Validation ;
1718
19+ /**
20+ * @group dns-sensitive
21+ */
1822class UrlValidatorTest extends AbstractConstraintValidatorTest
1923{
2024 protected function getApiVersion ()
@@ -187,6 +191,34 @@ public function getValidCustomUrls()
187191 array ('git://[::1]/ ' ),
188192 );
189193 }
194+
195+ /**
196+ * @dataProvider getCheckDns
197+ */
198+ public function testCheckDns ($ violation )
199+ {
200+ DnsMock::withMockedHosts (array ('example.com ' => array (array ('type ' => $ violation ? '' : 'A ' ))));
201+
202+ $ constraint = new Url (array (
203+ 'checkDNS ' => true ,
204+ 'dnsMessage ' => 'myMessage ' ,
205+ ));
206+
207+ $ this ->validator ->validate ('http://example.com ' , $ constraint );
208+
209+ if (!$ violation ) {
210+ $ this ->assertNoViolation ();
211+ } else {
212+ $ this ->buildViolation ('myMessage ' )
213+ ->setParameter ('{{ value }} ' , '"example.com" ' )
214+ ->assertRaised ();
215+ }
216+ }
217+
218+ public function getCheckDns ()
219+ {
220+ return array (array (true ), array (false ));
221+ }
190222}
191223
192224class EmailProvider
You can’t perform that action at this time.
0 commit comments