File tree 1 file changed +32
-0
lines changed
src/Symfony/Component/Validator/Tests/Constraints
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Validator \Tests \Constraints ;
13
13
14
+ use Symfony \Bridge \PhpUnit \DnsMock ;
14
15
use Symfony \Component \Validator \Constraints \Url ;
15
16
use Symfony \Component \Validator \Constraints \UrlValidator ;
16
17
use Symfony \Component \Validator \Validation ;
17
18
19
+ /**
20
+ * @group dns-sensitive
21
+ */
18
22
class UrlValidatorTest extends AbstractConstraintValidatorTest
19
23
{
20
24
protected function getApiVersion ()
@@ -187,6 +191,34 @@ public function getValidCustomUrls()
187
191
array ('git://[::1]/ ' ),
188
192
);
189
193
}
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
+ }
190
222
}
191
223
192
224
class EmailProvider
You can’t perform that action at this time.
0 commit comments