コード例 #1
0
 public function testGetGeocodedDataOmniServiceWithRealIPv6WithSsl()
 {
     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('::ffff:66.147.244.214');
     $this->assertInternalType('array', $result);
     $this->assertCount(1, $result);
     $result = $result[0];
     $this->assertInternalType('array', $result);
     $this->assertEquals(40.2181, $result['latitude'], '', 0.1);
     $this->assertEquals(-111.6133, $result['longitude'], '', 0.1);
     $this->assertEquals('Provo', $result['city']);
     $this->assertEquals(84606, $result['zipcode']);
     $this->assertEquals('UT', $result['regionCode']);
     $this->assertEquals('United States', $result['country']);
     $this->assertEquals('US', $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('Utah', $result['region']);
     $this->assertEquals('America/Denver', $result['timezone']);
 }
コード例 #2
0
 public function testGetGeocodedDataWithRealIPv4()
 {
     if (!isset($_SERVER['MAXMIND_API_KEY'])) {
         $this->markTestSkipped('You need to configure the MAXMIND_API_KEY value in phpunit.xml');
     }
     $provider = new MaxMindProvider(new \Geocoder\HttpAdapter\CurlHttpAdapter(), $_SERVER['MAXMIND_API_KEY']);
     $result = $provider->getGeocodedData('74.200.247.59');
     $this->assertEquals(33.034698486328, $result['latitude'], '', 0.0001);
     $this->assertEquals(-96.813400268555, $result['longitude'], '', 0.0001);
     $this->assertEquals('United States', $result['country']);
     $this->assertEquals('Plano', $result['city']);
     $this->assertEquals(75093, $result['zipcode']);
     $this->assertEquals('TX', $result['regionCode']);
     $this->assertEquals('United States', $result['country']);
     $this->assertEquals('US', $result['countryCode']);
 }