21
21
22
22
class MaxMindBinaryTest extends BaseTestCase
23
23
{
24
- private $ binaryFile ;
24
+ private string $ binaryFile ;
25
25
26
26
public function setUp (): void
27
27
{
28
28
$ this ->binaryFile = __DIR__ .'/fixtures/GeoLiteCity.dat ' ;
29
29
}
30
30
31
- protected function getCacheDir ()
31
+ protected function getCacheDir (): string
32
32
{
33
33
return __DIR__ .'/.cached_responses ' ;
34
34
}
@@ -44,23 +44,26 @@ public static function setUpBeforeClass(): void
44
44
}
45
45
}
46
46
47
- public static function provideIps ()
47
+ /**
48
+ * @return array<string, string[]>
49
+ */
50
+ public static function provideIps (): array
48
51
{
49
52
return [
50
53
'24.24.24.24 ' => ['24.24.24.24 ' , 'East Syracuse ' , 'United States ' ],
51
54
'80.24.24.24 ' => ['80.24.24.24 ' , 'Sabadell ' , 'Spain ' ],
52
55
];
53
56
}
54
57
55
- public function testThrowIfNotExistBinaryFileGiven ()
58
+ public function testThrowIfNotExistBinaryFileGiven (): void
56
59
{
57
60
$ this ->expectException (\Geocoder \Exception \InvalidArgument::class);
58
61
$ this ->expectExceptionMessage ('Given MaxMind dat file "not_exist.dat" does not exist. ' );
59
62
60
63
new MaxMindBinary ('not_exist.dat ' );
61
64
}
62
65
63
- public function testLocationResultContainsExpectedFieldsForAnAmericanIp ()
66
+ public function testLocationResultContainsExpectedFieldsForAnAmericanIp (): void
64
67
{
65
68
$ provider = new MaxMindBinary ($ this ->binaryFile );
66
69
$ results = $ provider ->geocodeQuery (GeocodeQuery::create ('24.24.24.24 ' ));
@@ -88,7 +91,7 @@ public function testLocationResultContainsExpectedFieldsForAnAmericanIp()
88
91
$ this ->assertNull ($ result ->getTimezone ());
89
92
}
90
93
91
- public function testLocationResultContainsExpectedFieldsForASpanishIp ()
94
+ public function testLocationResultContainsExpectedFieldsForASpanishIp (): void
92
95
{
93
96
$ provider = new MaxMindBinary ($ this ->binaryFile );
94
97
$ results = $ provider ->geocodeQuery (GeocodeQuery::create ('80.24.24.24 ' ));
@@ -119,7 +122,7 @@ public function testLocationResultContainsExpectedFieldsForASpanishIp()
119
122
/**
120
123
* @dataProvider provideIps
121
124
*/
122
- public function testFindLocationByIp ($ ip , $ expectedCity , $ expectedCountry )
125
+ public function testFindLocationByIp (string $ ip , ? string $ expectedCity , ? string $ expectedCountry ): void
123
126
{
124
127
$ provider = new MaxMindBinary ($ this ->binaryFile );
125
128
$ results = $ provider ->geocodeQuery (GeocodeQuery::create ($ ip ));
@@ -134,7 +137,7 @@ public function testFindLocationByIp($ip, $expectedCity, $expectedCountry)
134
137
$ this ->assertEquals ($ expectedCountry , $ result ->getCountry ()->getName ());
135
138
}
136
139
137
- public function testShouldReturnResultsAsUtf8Encoded ()
140
+ public function testShouldReturnResultsAsUtf8Encoded (): void
138
141
{
139
142
$ provider = new MaxMindBinary ($ this ->binaryFile );
140
143
$ results = $ provider ->geocodeQuery (GeocodeQuery::create ('212.51.181.237 ' ));
@@ -145,14 +148,14 @@ public function testShouldReturnResultsAsUtf8Encoded()
145
148
$ this ->assertSame ('Châlette-sur-loing ' , $ result ->getLocality ());
146
149
}
147
150
148
- public function testGetName ()
151
+ public function testGetName (): void
149
152
{
150
153
$ provider = new MaxMindBinary ($ this ->binaryFile );
151
154
152
155
$ this ->assertEquals ('maxmind_binary ' , $ provider ->getName ());
153
156
}
154
157
155
- public function testThrowIfIpAddressCouldNotBeLocated ()
158
+ public function testThrowIfIpAddressCouldNotBeLocated (): void
156
159
{
157
160
$ provider = new MaxMindBinary ($ this ->binaryFile );
158
161
$ result = $ provider ->geocodeQuery (GeocodeQuery::create ('127.0.0.1 ' ));
@@ -161,7 +164,7 @@ public function testThrowIfIpAddressCouldNotBeLocated()
161
164
$ this ->assertEquals (0 , $ result ->count ());
162
165
}
163
166
164
- public function testThrowIfIpAddressIsNotIpV4 ()
167
+ public function testThrowIfIpAddressIsNotIpV4 (): void
165
168
{
166
169
$ this ->expectException (\Geocoder \Exception \UnsupportedOperation::class);
167
170
$ this ->expectExceptionMessage ('The MaxMindBinary provider does not support IPv6 addresses. ' );
@@ -171,7 +174,7 @@ public function testThrowIfIpAddressIsNotIpV4()
171
174
$ provider ->geocodeQuery (GeocodeQuery::create ('2002:5018:1818:0:0:0:0:0 ' ));
172
175
}
173
176
174
- public function testThrowIfInvalidIpAddressGiven ()
177
+ public function testThrowIfInvalidIpAddressGiven (): void
175
178
{
176
179
$ this ->expectException (\Geocoder \Exception \UnsupportedOperation::class);
177
180
$ this ->expectExceptionMessage ('The MaxMindBinary provider does not support street addresses. ' );
@@ -181,7 +184,7 @@ public function testThrowIfInvalidIpAddressGiven()
181
184
$ provider ->geocodeQuery (GeocodeQuery::create ('invalidIp ' ));
182
185
}
183
186
184
- public function testThrowOnReverseMethodUsage ()
187
+ public function testThrowOnReverseMethodUsage (): void
185
188
{
186
189
$ this ->expectException (\Geocoder \Exception \UnsupportedOperation::class);
187
190
$ this ->expectExceptionMessage ('The MaxMindBinary is not able to do reverse geocoding. ' );
0 commit comments