20
20
*/
21
21
class TimezoneValidatorTest extends ConstraintValidatorTestCase
22
22
{
23
- protected function createValidator ()
23
+ protected function createValidator (): TimezoneValidator
24
24
{
25
25
return new TimezoneValidator ();
26
26
}
@@ -50,14 +50,14 @@ public function testExpectsStringCompatibleType()
50
50
/**
51
51
* @dataProvider getValidTimezones
52
52
*/
53
- public function testValidTimezones ($ timezone )
53
+ public function testValidTimezones (string $ timezone )
54
54
{
55
55
$ this ->validator ->validate ($ timezone , new Timezone ());
56
56
57
57
$ this ->assertNoViolation ();
58
58
}
59
59
60
- public function getValidTimezones ()
60
+ public function getValidTimezones (): iterable
61
61
{
62
62
return array (
63
63
array ('America/Argentina/Buenos_Aires ' ),
@@ -73,7 +73,7 @@ public function getValidTimezones()
73
73
/**
74
74
* @dataProvider getValidGroupedTimezones
75
75
*/
76
- public function testValidGroupedTimezones ($ timezone , $ what )
76
+ public function testValidGroupedTimezones (string $ timezone , int $ what )
77
77
{
78
78
$ constraint = new Timezone (array (
79
79
'zone ' => $ what ,
@@ -84,7 +84,7 @@ public function testValidGroupedTimezones($timezone, $what)
84
84
$ this ->assertNoViolation ();
85
85
}
86
86
87
- public function getValidGroupedTimezones ()
87
+ public function getValidGroupedTimezones (): iterable
88
88
{
89
89
return array (
90
90
array ('America/Argentina/Cordoba ' , \DateTimeZone::AMERICA ),
@@ -106,7 +106,7 @@ public function getValidGroupedTimezones()
106
106
/**
107
107
* @dataProvider getInvalidTimezones
108
108
*/
109
- public function testInvalidTimezonesWithoutZone ($ timezone , $ extraInfo )
109
+ public function testInvalidTimezonesWithoutZone (string $ timezone , string $ zoneMessage , string $ countryCodeMessage )
110
110
{
111
111
$ constraint = new Timezone (array (
112
112
'message ' => 'myMessage ' ,
@@ -115,24 +115,25 @@ public function testInvalidTimezonesWithoutZone($timezone, $extraInfo)
115
115
$ this ->validator ->validate ($ timezone , $ constraint );
116
116
117
117
$ this ->buildViolation ('myMessage ' )
118
- ->setParameter ('{{ extra_info }} ' , $ extraInfo )
118
+ ->setParameter ('{{ zone_message }} ' , $ zoneMessage )
119
+ ->setParameter ('{{ country_code_message }} ' , $ countryCodeMessage )
119
120
->setCode (Timezone::NO_SUCH_TIMEZONE_ERROR )
120
121
->assertRaised ();
121
122
}
122
123
123
- public function getInvalidTimezones ()
124
+ public function getInvalidTimezones (): iterable
124
125
{
125
126
return array (
126
- array ('Buenos_Aires/Argentina/America ' , '' ),
127
- array ('Mayotte/Indian ' , '' ),
128
- array ('foobar ' , '' ),
127
+ array ('Buenos_Aires/Argentina/America ' , '' , '' ),
128
+ array ('Mayotte/Indian ' , '' , '' ),
129
+ array ('foobar ' , '' , '' ),
129
130
);
130
131
}
131
132
132
133
/**
133
134
* @dataProvider getInvalidGroupedTimezones
134
135
*/
135
- public function testInvalidGroupedTimezones ($ timezone , $ what , $ extraInfo )
136
+ public function testInvalidGroupedTimezones (string $ timezone , int $ what , string $ zoneMessage , string $ countryCodeMessage )
136
137
{
137
138
$ constraint = new Timezone (array (
138
139
'zone ' => $ what ,
@@ -142,26 +143,27 @@ public function testInvalidGroupedTimezones($timezone, $what, $extraInfo)
142
143
$ this ->validator ->validate ($ timezone , $ constraint );
143
144
144
145
$ this ->buildViolation ('myMessage ' )
145
- ->setParameter ('{{ extra_info }} ' , $ extraInfo )
146
+ ->setParameter ('{{ zone_message }} ' , $ zoneMessage )
147
+ ->setParameter ('{{ country_code_message }} ' , $ countryCodeMessage )
146
148
->setCode (Timezone::NO_SUCH_TIMEZONE_IN_ZONE_ERROR )
147
149
->assertRaised ();
148
150
}
149
151
150
- public function getInvalidGroupedTimezones ()
152
+ public function getInvalidGroupedTimezones (): iterable
151
153
{
152
154
return array (
153
- array ('Antarctica/McMurdo ' , \DateTimeZone::AMERICA , ' for "AMERICA" zone ' ),
154
- array ('America/Barbados ' , \DateTimeZone::ANTARCTICA , ' for "ANTARCTICA" zone ' ),
155
- array ('Europe/Kiev ' , \DateTimeZone::ARCTIC , ' for "ARCTIC" zone ' ),
156
- array ('Asia/Ho_Chi_Minh ' , \DateTimeZone::INDIAN , ' for "INDIAN" zone ' ),
157
- array ('Asia/Ho_Chi_Minh ' , \DateTimeZone::INDIAN | \DateTimeZone::ANTARCTICA , ' for zone with identifier 260 ' ),
155
+ array ('Antarctica/McMurdo ' , \DateTimeZone::AMERICA , ' at "AMERICA" zone ' , ' ' ),
156
+ array ('America/Barbados ' , \DateTimeZone::ANTARCTICA , ' at "ANTARCTICA" zone ' , ' ' ),
157
+ array ('Europe/Kiev ' , \DateTimeZone::ARCTIC , ' at "ARCTIC" zone ' , ' ' ),
158
+ array ('Asia/Ho_Chi_Minh ' , \DateTimeZone::INDIAN , ' at "INDIAN" zone ' , ' ' ),
159
+ array ('Asia/Ho_Chi_Minh ' , \DateTimeZone::INDIAN | \DateTimeZone::ANTARCTICA , ' at zone with identifier 260 ' , ' ' ),
158
160
);
159
161
}
160
162
161
163
/**
162
164
* @dataProvider getValidGroupedTimezonesByCountry
163
165
*/
164
- public function testValidGroupedTimezonesByCountry ($ timezone , $ what , $ country )
166
+ public function testValidGroupedTimezonesByCountry (string $ timezone , int $ what , string $ country )
165
167
{
166
168
$ constraint = new Timezone (array (
167
169
'zone ' => $ what ,
@@ -173,7 +175,7 @@ public function testValidGroupedTimezonesByCountry($timezone, $what, $country)
173
175
$ this ->assertNoViolation ();
174
176
}
175
177
176
- public function getValidGroupedTimezonesByCountry ()
178
+ public function getValidGroupedTimezonesByCountry (): iterable
177
179
{
178
180
return array (
179
181
array ('America/Argentina/Cordoba ' , \DateTimeZone::PER_COUNTRY , 'AR ' ),
@@ -195,7 +197,7 @@ public function getValidGroupedTimezonesByCountry()
195
197
/**
196
198
* @dataProvider getInvalidGroupedTimezonesByCountry
197
199
*/
198
- public function testInvalidGroupedTimezonesByCountry ($ timezone , $ what , $ country , $ extraInfo )
200
+ public function testInvalidGroupedTimezonesByCountry (string $ timezone , int $ what , string $ country , string $ zoneMessage , string $ countryCodeMessage )
199
201
{
200
202
$ constraint = new Timezone (array (
201
203
'message ' => 'myMessage ' ,
@@ -206,23 +208,24 @@ public function testInvalidGroupedTimezonesByCountry($timezone, $what, $country,
206
208
$ this ->validator ->validate ($ timezone , $ constraint );
207
209
208
210
$ this ->buildViolation ('myMessage ' )
209
- ->setParameter ('{{ extra_info }} ' , $ extraInfo )
211
+ ->setParameter ('{{ zone_message }} ' , $ zoneMessage )
212
+ ->setParameter ('{{ country_code_message }} ' , $ countryCodeMessage )
210
213
->setCode (Timezone::NO_SUCH_TIMEZONE_IN_COUNTRY_ERROR )
211
214
->assertRaised ();
212
215
}
213
216
214
- public function getInvalidGroupedTimezonesByCountry ()
217
+ public function getInvalidGroupedTimezonesByCountry (): iterable
215
218
{
216
219
return array (
217
- array ('America/Argentina/Cordoba ' , \DateTimeZone::PER_COUNTRY , 'FR ' , ' for ISO 3166-1 country code "FR" ' ),
218
- array ('America/Barbados ' , \DateTimeZone::PER_COUNTRY , 'PT ' , ' for ISO 3166-1 country code "PT" ' ),
220
+ array ('America/Argentina/Cordoba ' , \DateTimeZone::PER_COUNTRY , 'FR ' , '' , ' for ISO 3166-1 country code "FR" ' ),
221
+ array ('America/Barbados ' , \DateTimeZone::PER_COUNTRY , 'PT ' , '' , ' for ISO 3166-1 country code "PT" ' ),
219
222
);
220
223
}
221
224
222
225
/**
223
226
* @dataProvider getDeprecatedTimezones
224
227
*/
225
- public function testDeprecatedTimezonesAreVaildWithBC ($ timezone )
228
+ public function testDeprecatedTimezonesAreVaildWithBC (string $ timezone )
226
229
{
227
230
$ constraint = new Timezone (array (
228
231
'zone ' => \DateTimeZone::ALL_WITH_BC ,
@@ -236,7 +239,7 @@ public function testDeprecatedTimezonesAreVaildWithBC($timezone)
236
239
/**
237
240
* @dataProvider getDeprecatedTimezones
238
241
*/
239
- public function testDeprecatedTimezonesAreInvaildWithoutBC ($ timezone )
242
+ public function testDeprecatedTimezonesAreInvaildWithoutBC (string $ timezone )
240
243
{
241
244
$ constraint = new Timezone (array (
242
245
'message ' => 'myMessage ' ,
@@ -245,12 +248,13 @@ public function testDeprecatedTimezonesAreInvaildWithoutBC($timezone)
245
248
$ this ->validator ->validate ($ timezone , $ constraint );
246
249
247
250
$ this ->buildViolation ('myMessage ' )
248
- ->setParameter ('{{ extra_info }} ' , '' )
251
+ ->setParameter ('{{ zone_message }} ' , '' )
252
+ ->setParameter ('{{ country_code_message }} ' , '' )
249
253
->setCode (Timezone::NO_SUCH_TIMEZONE_ERROR )
250
254
->assertRaised ();
251
255
}
252
256
253
- public function getDeprecatedTimezones ()
257
+ public function getDeprecatedTimezones (): iterable
254
258
{
255
259
return array (
256
260
array ('America/Buenos_Aires ' ),
0 commit comments