From b4ab4c1b9c5df0971c2e109c380aedd870ae3e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Beli=C3=ABn?= Date: Thu, 22 Nov 2018 16:14:18 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverse geocoding with radius --- ...e_a20411268a693b9100cc92221e97d420ee75cb9e | 1 + Tests/Geo6Test.php | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 Tests/.cached_responses/api.geo6.be_a20411268a693b9100cc92221e97d420ee75cb9e diff --git a/Tests/.cached_responses/api.geo6.be_a20411268a693b9100cc92221e97d420ee75cb9e b/Tests/.cached_responses/api.geo6.be_a20411268a693b9100cc92221e97d420ee75cb9e new file mode 100644 index 0000000..e9ddb90 --- /dev/null +++ b/Tests/.cached_responses/api.geo6.be_a20411268a693b9100cc92221e97d420ee75cb9e @@ -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}]}"; \ No newline at end of file diff --git a/Tests/Geo6Test.php b/Tests/Geo6Test.php index d06e33c..dd427d6 100644 --- a/Tests/Geo6Test.php +++ b/Tests/Geo6Test.php @@ -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'])) {