Skip to content

Commit 11f8bbf

Browse files
toin0uwilldurand
authored andcommitted
Add tests for encoding issue with MaxMind provider
1 parent 51f4688 commit 11f8bbf

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s:187:"US,"United States",UT,Utah,Provo,40.2181,-111.6133,770,801,America/Denver,NA,84606,"Unified Layer","Unified Layer",bluehost.com,"AS46606 Unified Layer",Corporate,residential,999,83,5,5,5,";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s:79:"US,UT,Provo,84606,40.218102,-111.613297,770,801,"Unified Layer","Unified Layer"";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s:96:"BR,26,Florian�polis,,-27.583300,-48.566700,0,0,"Global Village Telecom","Global Village Telecom"";

tests/Geocoder/Tests/Provider/MaxMindTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,39 @@ public function testGeocodeOmniServiceWithRealIPv4()
362362
$this->assertEquals('America/Chicago', $result->getTimezone());
363363
}
364364

365+
public function testGeocodeOmniServiceWithRealIPv4WithSslAndEncoding()
366+
{
367+
if (!isset($_SERVER['MAXMIND_API_KEY'])) {
368+
$this->markTestSkipped('You need to configure the MAXMIND_API_KEY value in phpunit.xml');
369+
}
370+
371+
$provider = new MaxMind($this->getAdapter(), $_SERVER['MAXMIND_API_KEY'],
372+
MaxMind::OMNI_SERVICE, true);
373+
$results = $provider->geocode('189.26.128.80');
374+
375+
$this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
376+
$this->assertCount(1, $results);
377+
378+
/** @var \Geocoder\Model\Address $result */
379+
$result = $results->first();
380+
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
381+
$this->assertEquals(-27.5833, $result->getLatitude(), '', 0.1);
382+
$this->assertEquals(-48.5666, $result->getLongitude(), '', 0.1);
383+
$this->assertFalse($result->getBounds()->isDefined());
384+
$this->assertNull($result->getStreetNumber());
385+
$this->assertNull($result->getStreetName());
386+
$this->assertNull($result->getPostalCode());
387+
$this->assertEquals('Florianópolis', $result->getLocality());
388+
$this->assertNull($result->getSubLocality());
389+
$this->assertNull($result->getCounty()->getName());
390+
$this->assertNull($result->getCounty()->getCode());
391+
$this->assertEquals('Santa Catarina', $result->getRegion()->getName());
392+
$this->assertEquals('26', $result->getRegion()->getCode());
393+
$this->assertEquals('Brazil', $result->getCountry()->getName());
394+
$this->assertEquals('BR', $result->getCountry()->getCode());
395+
$this->assertEquals('America/Sao_Paulo', $result->getTimezone());
396+
}
397+
365398
public function testGeocodeWithRealIPv6()
366399
{
367400
if (!isset($_SERVER['MAXMIND_API_KEY'])) {

0 commit comments

Comments
 (0)