File tree 4 files changed +43
-4
lines changed
Validator/Tests/Constraints 4 files changed +43
-4
lines changed Original file line number Diff line number Diff line change 11
11
*/
12
12
13
13
// Please update when phpunit needs to be reinstalled with fresh deps:
14
- // Cache-Id-Version: 2015-11-28 09:05 UTC
14
+ // Cache-Id-Version: 2016-03-16 15:36 UTC
15
15
16
16
use Symfony \Component \Process \ProcessUtils ;
17
17
@@ -52,7 +52,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
52
52
$ zip ->close ();
53
53
chdir ("phpunit- $ PHPUNIT_VERSION " );
54
54
passthru ("$ COMPOSER remove --no-update symfony/yaml " );
55
- passthru ("$ COMPOSER require --dev --no-update symfony/phpunit-bridge \">=2.8 @dev \"" );
55
+ passthru ("$ COMPOSER require --dev --no-update symfony/phpunit-bridge \">=3.1 @dev \"" );
56
56
passthru ("$ COMPOSER install --prefer-dist --no-progress --ansi " );
57
57
file_put_contents ('phpunit ' , <<<EOPHP
58
58
<?php
Original file line number Diff line number Diff line change 50
50
<listener class =" Symfony\Bridge\PhpUnit\SymfonyTestsListener" >
51
51
<arguments >
52
52
<array >
53
- <element ><string >Symfony\Component\HttpFoundation</string ></element >
53
+ <element key = " time-sensitive " ><string >Symfony\Component\HttpFoundation</string ></element >
54
54
</array >
55
55
</arguments >
56
56
</listener >
Original file line number Diff line number Diff line change 30
30
<listener class =" Symfony\Bridge\PhpUnit\SymfonyTestsListener" >
31
31
<arguments >
32
32
<array >
33
- <element ><string >Symfony\Component\HttpFoundation</string ></element >
33
+ <element key = " time-sensitive " ><string >Symfony\Component\HttpFoundation</string ></element >
34
34
</array >
35
35
</arguments >
36
36
</listener >
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 \Email ;
15
16
use Symfony \Component \Validator \Constraints \EmailValidator ;
16
17
18
+ /**
19
+ * @group dns-sensitive
20
+ */
17
21
class EmailValidatorTest extends AbstractConstraintValidatorTest
18
22
{
19
23
protected function createValidator ()
@@ -86,4 +90,39 @@ public function getInvalidEmails()
86
90
array ('example@localhost ' ),
87
91
);
88
92
}
93
+
94
+ /**
95
+ * @dataProvider getDnsChecks
96
+ */
97
+ public function testDnsChecks ($ type , $ violation )
98
+ {
99
+ DnsMock::withMockedHosts (array ('example.com ' => array (array ('type ' => $ violation ? false : $ type ))));
100
+
101
+ $ constraint = new Email (array (
102
+ 'message ' => 'myMessage ' ,
103
+ 'MX ' === $ type ? 'checkMX ' : 'checkHost ' => true ,
104
+ ));
105
+
106
+ $ this ->validator ->validate ('foo@example.com ' , $ constraint );
107
+
108
+ if (!$ violation ) {
109
+ $ this ->assertNoViolation ();
110
+ } else {
111
+ $ this ->buildViolation ('myMessage ' )
112
+ ->setParameter ('{{ value }} ' , '"foo@example.com" ' )
113
+ ->assertRaised ();
114
+ }
115
+ }
116
+
117
+ public function getDnsChecks ()
118
+ {
119
+ return array (
120
+ array ('MX ' , false ),
121
+ array ('MX ' , true ),
122
+ array ('A ' , false ),
123
+ array ('A ' , true ),
124
+ array ('AAAA ' , false ),
125
+ array ('AAAA ' , true ),
126
+ );
127
+ }
89
128
}
You can’t perform that action at this time.
0 commit comments