2121
2222class MaxMindBinaryTest extends BaseTestCase
2323{
24- private $ binaryFile ;
24+ private string $ binaryFile ;
2525
2626 public function setUp (): void
2727 {
2828 $ this ->binaryFile = __DIR__ .'/fixtures/GeoLiteCity.dat ' ;
2929 }
3030
31- protected function getCacheDir ()
31+ protected function getCacheDir (): string
3232 {
3333 return __DIR__ .'/.cached_responses ' ;
3434 }
@@ -44,23 +44,26 @@ public static function setUpBeforeClass(): void
4444 }
4545 }
4646
47- public static function provideIps ()
47+ /**
48+ * @return array<string, string[]>
49+ */
50+ public static function provideIps (): array
4851 {
4952 return [
5053 '24.24.24.24 ' => ['24.24.24.24 ' , 'East Syracuse ' , 'United States ' ],
5154 '80.24.24.24 ' => ['80.24.24.24 ' , 'Sabadell ' , 'Spain ' ],
5255 ];
5356 }
5457
55- public function testThrowIfNotExistBinaryFileGiven ()
58+ public function testThrowIfNotExistBinaryFileGiven (): void
5659 {
5760 $ this ->expectException (\Geocoder \Exception \InvalidArgument::class);
5861 $ this ->expectExceptionMessage ('Given MaxMind dat file "not_exist.dat" does not exist. ' );
5962
6063 new MaxMindBinary ('not_exist.dat ' );
6164 }
6265
63- public function testLocationResultContainsExpectedFieldsForAnAmericanIp ()
66+ public function testLocationResultContainsExpectedFieldsForAnAmericanIp (): void
6467 {
6568 $ provider = new MaxMindBinary ($ this ->binaryFile );
6669 $ results = $ provider ->geocodeQuery (GeocodeQuery::create ('24.24.24.24 ' ));
@@ -88,7 +91,7 @@ public function testLocationResultContainsExpectedFieldsForAnAmericanIp()
8891 $ this ->assertNull ($ result ->getTimezone ());
8992 }
9093
91- public function testLocationResultContainsExpectedFieldsForASpanishIp ()
94+ public function testLocationResultContainsExpectedFieldsForASpanishIp (): void
9295 {
9396 $ provider = new MaxMindBinary ($ this ->binaryFile );
9497 $ results = $ provider ->geocodeQuery (GeocodeQuery::create ('80.24.24.24 ' ));
@@ -119,7 +122,7 @@ public function testLocationResultContainsExpectedFieldsForASpanishIp()
119122 /**
120123 * @dataProvider provideIps
121124 */
122- public function testFindLocationByIp ($ ip , $ expectedCity , $ expectedCountry )
125+ public function testFindLocationByIp (string $ ip , ? string $ expectedCity , ? string $ expectedCountry ): void
123126 {
124127 $ provider = new MaxMindBinary ($ this ->binaryFile );
125128 $ results = $ provider ->geocodeQuery (GeocodeQuery::create ($ ip ));
@@ -134,7 +137,7 @@ public function testFindLocationByIp($ip, $expectedCity, $expectedCountry)
134137 $ this ->assertEquals ($ expectedCountry , $ result ->getCountry ()->getName ());
135138 }
136139
137- public function testShouldReturnResultsAsUtf8Encoded ()
140+ public function testShouldReturnResultsAsUtf8Encoded (): void
138141 {
139142 $ provider = new MaxMindBinary ($ this ->binaryFile );
140143 $ results = $ provider ->geocodeQuery (GeocodeQuery::create ('212.51.181.237 ' ));
@@ -145,14 +148,14 @@ public function testShouldReturnResultsAsUtf8Encoded()
145148 $ this ->assertSame ('Châlette-sur-loing ' , $ result ->getLocality ());
146149 }
147150
148- public function testGetName ()
151+ public function testGetName (): void
149152 {
150153 $ provider = new MaxMindBinary ($ this ->binaryFile );
151154
152155 $ this ->assertEquals ('maxmind_binary ' , $ provider ->getName ());
153156 }
154157
155- public function testThrowIfIpAddressCouldNotBeLocated ()
158+ public function testThrowIfIpAddressCouldNotBeLocated (): void
156159 {
157160 $ provider = new MaxMindBinary ($ this ->binaryFile );
158161 $ result = $ provider ->geocodeQuery (GeocodeQuery::create ('127.0.0.1 ' ));
@@ -161,7 +164,7 @@ public function testThrowIfIpAddressCouldNotBeLocated()
161164 $ this ->assertEquals (0 , $ result ->count ());
162165 }
163166
164- public function testThrowIfIpAddressIsNotIpV4 ()
167+ public function testThrowIfIpAddressIsNotIpV4 (): void
165168 {
166169 $ this ->expectException (\Geocoder \Exception \UnsupportedOperation::class);
167170 $ this ->expectExceptionMessage ('The MaxMindBinary provider does not support IPv6 addresses. ' );
@@ -171,7 +174,7 @@ public function testThrowIfIpAddressIsNotIpV4()
171174 $ provider ->geocodeQuery (GeocodeQuery::create ('2002:5018:1818:0:0:0:0:0 ' ));
172175 }
173176
174- public function testThrowIfInvalidIpAddressGiven ()
177+ public function testThrowIfInvalidIpAddressGiven (): void
175178 {
176179 $ this ->expectException (\Geocoder \Exception \UnsupportedOperation::class);
177180 $ this ->expectExceptionMessage ('The MaxMindBinary provider does not support street addresses. ' );
@@ -181,7 +184,7 @@ public function testThrowIfInvalidIpAddressGiven()
181184 $ provider ->geocodeQuery (GeocodeQuery::create ('invalidIp ' ));
182185 }
183186
184- public function testThrowOnReverseMethodUsage ()
187+ public function testThrowOnReverseMethodUsage (): void
185188 {
186189 $ this ->expectException (\Geocoder \Exception \UnsupportedOperation::class);
187190 $ this ->expectExceptionMessage ('The MaxMindBinary is not able to do reverse geocoding. ' );
0 commit comments