diff --git a/src/Geocoder/Provider/MaxMindProvider.php b/src/Geocoder/Provider/MaxMindProvider.php index f62c89644..1f62fb98c 100644 --- a/src/Geocoder/Provider/MaxMindProvider.php +++ b/src/Geocoder/Provider/MaxMindProvider.php @@ -139,7 +139,7 @@ protected function executeQuery($query) $data['country'] = $this->countryCodeToCountryName($data['countryCode']); } - return array(array_merge($this->getDefaults(), $data)); + return array($this->fixEncoding(array_merge($this->getDefaults(), $data))); } /** diff --git a/tests/.cached_responses/b0b4edb754ec522d7b4ba93b159fa9b68e628393 b/tests/.cached_responses/b0b4edb754ec522d7b4ba93b159fa9b68e628393 new file mode 100644 index 000000000..8ef0effd4 --- /dev/null +++ b/tests/.cached_responses/b0b4edb754ec522d7b4ba93b159fa9b68e628393 @@ -0,0 +1 @@ +s:215:"BR,Brazil,26,"Santa Catarina",Florianópolis,-27.5833,-48.5667,,,America/Sao_Paulo,SA,,"Global Village Telecom","Global Village Telecom",gvt.net.br,"AS18881 Global Village Telecom",Cable/DSL,residential,18,99,52,92,,"; \ No newline at end of file diff --git a/tests/Geocoder/Tests/Provider/MaxMindProviderTest.php b/tests/Geocoder/Tests/Provider/MaxMindProviderTest.php index aa4dec5c7..54794edbd 100644 --- a/tests/Geocoder/Tests/Provider/MaxMindProviderTest.php +++ b/tests/Geocoder/Tests/Provider/MaxMindProviderTest.php @@ -369,6 +369,38 @@ public function testGetGeocodedDataOmniServiceWithRealIPv4() $this->assertEquals('America/Chicago', $result['timezone']); } + public function testGeocodeOmniServiceWithRealIPv4WithSslAndEncoding() + { + if (!isset($_SERVER['MAXMIND_API_KEY'])) { + $this->markTestSkipped('You need to configure the MAXMIND_API_KEY value in phpunit.xml'); + } + + $provider = new MaxMindProvider($this->getAdapter(), $_SERVER['MAXMIND_API_KEY'], + MaxMindProvider::OMNI_SERVICE, true); + $result = $provider->getGeocodedData('189.26.128.80'); + + $this->assertInternalType('array', $result); + $this->assertCount(1, $result); + + $result = $result[0]; + $this->assertInternalType('array', $result); + $this->assertEquals(-27.5833, $result['latitude'], '', 0.1); + $this->assertEquals(-48.5666, $result['longitude'], '', 0.1); + $this->assertEquals('Florianópolis', $result['city']); + $this->assertNull($result['zipcode']); + $this->assertEquals('26', $result['regionCode']); + $this->assertEquals('Brazil', $result['country']); + $this->assertEquals('BR', $result['countryCode']); + $this->assertNull($result['bounds']); + $this->assertNull($result['streetNumber']); + $this->assertNull($result['streetName']); + $this->assertNull($result['cityDistrict']); + $this->assertNull($result['county']); + $this->assertNull($result['countyCode']); + $this->assertEquals('Santa Catarina', $result['region']); + $this->assertEquals('America/Sao_Paulo', $result['timezone']); + } + public function testGetGeocodedDataWithRealIPv6() { if (!isset($_SERVER['MAXMIND_API_KEY'])) {