Skip to content

Commit

Permalink
✅ Add test
Browse files Browse the repository at this point in the history
Reverse geocoding with radius
  • Loading branch information
jbelien committed Nov 22, 2018
1 parent 1a0fc9a commit b4ab4c1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
s:1772:"{"type":"FeatureCollection","query":{"lat":50.841973,"lng":4.362288},"features":[{"type":"Feature","id":1000,"properties":{"type":"postal_code","name_fr":"BRUXELLES","name_nl":"BRUSSEL"},"geometry":null},{"type":"Feature","id":21004,"properties":{"type":"municipality","name_fr":"BRUXELLES","name_nl":"BRUSSEL","image":null},"geometry":null},{"type":"Feature","properties":{"type":"province","name_fr":null,"name_nl":null},"geometry":null},{"type":"Feature","properties":{"type":"region","name_fr":"R\u00e9gion de Bruxelles-Capitale","name_nl":"Brussels Hoofdstedelijk Gewest"},"geometry":null},{"type":"Feature","properties":{"type":"country","name_fr":"Belgique","name_nl":"Belgi\u00eb"},"geometry":null},{"type":"Feature","properties":{"type":"judicial_district","name_fr":"Bruxelles-Brussel, Hal, Vilvoorde","name_nl":"Bruxelles-Brussel, Hal, Vilvoorde","image":null},"geometry":null},{"type":"Feature","properties":{"type":"judicial_district_before2012","name_fr":"Bruxelles\/brussel\/halle\/vilvoorde","name_nl":"Bruxelles\/brussel\/halle\/vilvoorde","image":null},"geometry":null},{"type":"Feature","properties":{"type":"judicial_canton","name_fr":"Bruxelles \/ Brussel","name_nl":"Bruxelles \/ Brussel","image":null},"geometry":null},{"type":"Feature","properties":{"type":"police","name_fr":"PZ5339","name_nl":"PZ5339","image":null},"geometry":null},{"type":"Feature","properties":{"type":"civil_protection","name_fr":"I UOE Liedekerke","name_nl":"I UOE Liedekerke","image":null},"geometry":null},{"type":"Feature","properties":{"type":"emergency","name_fr":"Bruxelles-Brussel","name_nl":"Bruxelles-Brussel","image":null},"geometry":null},{"type":"Feature","properties":{"type":"fire_service","name_fr":"SIAMU","name_nl":"SIAMU","image":null},"geometry":null}]}";
26 changes: 26 additions & 0 deletions Tests/Geo6Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,32 @@ public function testReverseQuery()
$this->assertEquals('BRUXELLES', $result->getLocality());
}

public function testReverseQueryWithRadius()
{
if (!isset($_SERVER['GEO6_CUSTOMER_ID']) || !isset($_SERVER['GEO6_API_KEY'])) {
$this->markTestSkipped('You need to configure the GEO6_CUSTOMER_ID and GEO6_API_KEY value in phpunit.xml.dist');
}

$provider = new Geo6($this->getHttpClient(), $_SERVER['GEO6_CUSTOMER_ID'], $_SERVER['GEO6_API_KEY']);

$query = ReverseQuery::fromCoordinates(50.841973, 4.362288)
->withLocale('fr')
->withData('radius', 100);

$results = $provider->reverseQuery($query);

$this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
$this->assertCount(1, $results);

/** @var \Geocoder\Model\Address $result */
$result = $results->first();
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
$this->assertEquals(50.841973, $result->getCoordinates()->getLatitude(), '', 0.00001);
$this->assertEquals(4.362288, $result->getCoordinates()->getLongitude(), '', 0.00001);
$this->assertEquals('1000', $result->getPostalCode());
$this->assertEquals('BRUXELLES', $result->getLocality());
}

public function testGeocodeQuery()
{
if (!isset($_SERVER['GEO6_CUSTOMER_ID']) || !isset($_SERVER['GEO6_API_KEY'])) {
Expand Down

0 comments on commit b4ab4c1

Please sign in to comment.