Skip to content

Commit

Permalink
Fix Notice: Undefined variables (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineLemaire authored Feb 8, 2020
1 parent 3c3d6f3 commit 69de6ef
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Addok.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public function geocodeQuery(GeocodeQuery $query): Collection
$streetName = !empty($feature->properties->name) ? $feature->properties->name : null;
$number = null;
break;
default:
$streetName = null;
$number = null;
}
$locality = !empty($feature->properties->city) ? $feature->properties->city : null;
$postalCode = !empty($feature->properties->postcode) ? $feature->properties->postcode : null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
s:2186:"{"type": "FeatureCollection", "version": "draft", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [2.902793, 48.95732]}, "properties": {"label": "Meaux", "score": 0.953655878055982, "id": "77284", "type": "municipality", "name": "Meaux", "postcode": "77100", "citycode": "77284", "x": 692881.35, "y": 6873044.75, "population": 54331, "city": "Meaux", "context": "77, Seine-et-Marne, \u00cele-de-France", "importance": 0.4902146586158028}}, {"type": "Feature", "geometry": {"type": "Point", "coordinates": [0.832005, 44.381787]}, "properties": {"label": "Meaux 47140 Penne-d'Agenais", "score": 0.9425401404470107, "id": "47203_gs7zs8", "type": "street", "x": 527299.67, "y": 6367121.01, "importance": 0.36794154491711767, "name": "Meaux", "postcode": "47140", "citycode": "47203", "city": "Penne-d'Agenais", "context": "47, Lot-et-Garonne, Nouvelle-Aquitaine"}}, {"type": "Feature", "geometry": {"type": "Point", "coordinates": [1.124876, 44.493915]}, "properties": {"label": "Meaux 46700 Puy-l'\u00c9v\u00eaque", "score": 0.9417678006111074, "id": "46231_xzty39", "type": "street", "x": 550920.52, "y": 6378976.21, "importance": 0.3594458067221826, "name": "Meaux", "postcode": "46700", "citycode": "46231", "city": "Puy-l'\u00c9v\u00eaque", "context": "46, Lot, Occitanie"}}, {"type": "Feature", "geometry": {"type": "Point", "coordinates": [4.986327, 44.753059]}, "properties": {"label": "Meaux 26400 Eurre", "score": 0.9398672246541316, "id": "26125_1jwuzn", "type": "street", "x": 857194.69, "y": 6407968.73, "importance": 0.33853947119544897, "name": "Meaux", "postcode": "26400", "citycode": "26125", "city": "Eurre", "context": "26, Dr\u00f4me, Auvergne-Rh\u00f4ne-Alpes"}}, {"type": "Feature", "geometry": {"type": "Point", "coordinates": [2.501585, 46.786506]}, "properties": {"label": "Meaux 18200 Meillant", "score": 0.9369535280132067, "id": "18142_10iadg", "type": "street", "x": 661977.8, "y": 6631938.98, "importance": 0.3064888081452747, "name": "Meaux", "postcode": "18200", "citycode": "18142", "city": "Meillant", "context": "18, Cher, Centre-Val de Loire"}}], "attribution": "BAN", "licence": "ETALAB-2.0", "query": "Meaux", "limit": 5}";
18 changes: 18 additions & 0 deletions Tests/AddokTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,22 @@ public function testGeocodeQuery()
$this->assertEquals('95000', $result->getPostalCode());
$this->assertEquals('Cergy', $result->getLocality());
}

public function testGeocodeOnlyCityQuery()
{
$provider = Addok::withBANServer($this->getHttpClient(), 'Geocoder PHP/Addok Provider/Addok Test');
$results = $provider->geocodeQuery(GeocodeQuery::create('Meaux'));

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

/** @var \Geocoder\Model\Address $result */
$result = $results->first();
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
$this->assertEquals(48.95732, $result->getCoordinates()->getLatitude(), '', 0.00001);
$this->assertEquals(2.902793, $result->getCoordinates()->getLongitude(), '', 0.00001);
$this->assertNull($result->getStreetNumber());
$this->assertNull($result->getStreetName());
$this->assertEquals('77100', $result->getPostalCode());
$this->assertEquals('Meaux', $result->getLocality());
}
}

0 comments on commit 69de6ef

Please sign in to comment.