@@ -132,28 +132,69 @@ public function hostname_delete()
132
132
133
133
$ this ->assertFalse ($ this ->hostname ->exists );
134
134
}
135
+
136
+ /**
137
+ * @test
138
+ * @dataProvider matchHostnames
139
+ */
140
+ public function hostname_regex_validation_matches (string $ hostname )
141
+ {
142
+ $ this ->hostname ->fqdn = $ hostname ;
143
+ $ this ->hostnames ->create ($ this ->hostname );
144
+ $ this ->assertTrue ($ this ->hostname ->exists );
145
+ }
146
+
135
147
/**
136
148
* @test
149
+ * @dataProvider noMatchHostnames
137
150
*/
138
- public function hostname_regex_validation ( )
151
+ public function hostname_regex_validation_no_matches ( string $ hostname )
139
152
{
140
- $ matchhostnames = ["xn-fsqu00a.xn-0zwm56d " ,"xn-fsqu00a.xn--vermgensberatung-pwb " ,"xn--stackoverflow.com " ,"stackoverflow.xn--com " ,"stackoverflow.co.uk " ,"google.com.au " ,"i.oh1.me " ,"wow.british-library.uk " ,"xn--stackoverflow.com " ,"stackoverflow.xn--com " ,"stackoverflow.co.uk " ,"0-0O_.COM " ,"a.net " ,"0-0O.COM " ,"0-OZ.CO.uk " ,"0-TENSION.COM.br " ,"0-WH-AO14-0.COM-com.net " ,"a-1234567890-1234567890-1234567890-1234567890-1234567890-1234-z.eu.us " ,"subA.subB.subC.example.com " ,"*.subA.subB.example.com " ];
141
- $ nomatchhostnames = ["-0-0O.COM " ,"0-0O.-COM " ,"-a.dot " ,"a-1234567890-1234567890-1234567890-1234567890-1234567890-12345-z.eu.us " ];
142
- foreach ($ matchhostnames as $ hostname ) {
143
- $ this ->hostname ->fqdn = $ hostname ;
153
+ $ this ->hostname ->fqdn = $ hostname ;
154
+ try {
144
155
$ this ->hostnames ->create ($ this ->hostname );
145
- $ this ->assertTrue ($ this ->hostname ->exists );
146
- }
147
- foreach ($ nomatchhostnames as $ hostname ) {
148
- $ this ->hostname ->fqdn = $ hostname ;
149
- try {
150
- $ this ->hostnames ->create ($ this ->hostname );
151
- } catch (ModelValidationException $ e ) {
152
- $ this ->assertStringContainsString ("The fqdn field format is invalid. " , $ e ->getMessage ());
153
- }
156
+ } catch (ModelValidationException $ e ) {
157
+ $ this ->assertStringContainsString (" fqdn " , $ e ->getMessage ());
158
+ $ this ->assertStringContainsString ("is invalid. " , $ e ->getMessage ());
154
159
}
155
160
}
156
161
162
+ protected function matchHostnames (): array
163
+ {
164
+ return [
165
+ ["xn-fsqu00a.xn-0zwm56d " ],
166
+ ["xn-fsqu00a.xn--vermgensberatung-pwb " ],
167
+ ["xn--stackoverflow.com " ],
168
+ ["stackoverflow.xn--com " ],
169
+ ["stackoverflow.co.uk " ],
170
+ ["google.com.au " ],
171
+ ["i.oh1.me " ],
172
+ ["wow.british-library.uk " ],
173
+ ["xn--stackoverflow.com " ],
174
+ ["stackoverflow.xn--com " ],
175
+ ["stackoverflow.co.uk " ],
176
+ ["0-0O_.COM " ],
177
+ ["a.net " ],
178
+ ["0-0O.COM " ],
179
+ ["0-OZ.CO.uk " ],
180
+ ["0-TENSION.COM.br " ],
181
+ ["0-WH-AO14-0.COM-com.net " ],
182
+ ["a-1234567890-1234567890-1234567890-1234567890-1234567890-1234-z.eu.us " ],
183
+ ["subA.subB.subC.example.com " ],
184
+ ["*.subA.subB.example.com " ],
185
+ ];
186
+ }
187
+
188
+ protected function noMatchHostnames (): array
189
+ {
190
+ return [
191
+ ["-0-0O.COM " ],
192
+ ["0-0O.-COM " ],
193
+ ["-a.dot " ],
194
+ ["a-1234567890-1234567890-1234567890-1234567890-1234567890-12345-z.eu.us " ]
195
+ ];
196
+ }
197
+
157
198
protected function duringSetUp (Application $ app )
158
199
{
159
200
$ this ->setUpWebsites ();
0 commit comments