Skip to content

Commit 69de6ef

Browse files
Fix Notice: Undefined variables (#4)
1 parent 3c3d6f3 commit 69de6ef

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

Addok.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ public function geocodeQuery(GeocodeQuery $query): Collection
103103
$streetName = !empty($feature->properties->name) ? $feature->properties->name : null;
104104
$number = null;
105105
break;
106+
default:
107+
$streetName = null;
108+
$number = null;
106109
}
107110
$locality = !empty($feature->properties->city) ? $feature->properties->city : null;
108111
$postalCode = !empty($feature->properties->postcode) ? $feature->properties->postcode : null;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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}";

Tests/AddokTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,22 @@ public function testGeocodeQuery()
8989
$this->assertEquals('95000', $result->getPostalCode());
9090
$this->assertEquals('Cergy', $result->getLocality());
9191
}
92+
93+
public function testGeocodeOnlyCityQuery()
94+
{
95+
$provider = Addok::withBANServer($this->getHttpClient(), 'Geocoder PHP/Addok Provider/Addok Test');
96+
$results = $provider->geocodeQuery(GeocodeQuery::create('Meaux'));
97+
98+
$this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
99+
100+
/** @var \Geocoder\Model\Address $result */
101+
$result = $results->first();
102+
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
103+
$this->assertEquals(48.95732, $result->getCoordinates()->getLatitude(), '', 0.00001);
104+
$this->assertEquals(2.902793, $result->getCoordinates()->getLongitude(), '', 0.00001);
105+
$this->assertNull($result->getStreetNumber());
106+
$this->assertNull($result->getStreetName());
107+
$this->assertEquals('77100', $result->getPostalCode());
108+
$this->assertEquals('Meaux', $result->getLocality());
109+
}
92110
}

0 commit comments

Comments
 (0)