Skip to content

Commit d041314

Browse files
committed
add test to MapQuest provider when we get not relevant data from the api
1 parent d987747 commit d041314

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/Geocoder/Provider/MapQuestProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ protected function executeQuery($query)
160160

161161
if (empty($results)) {
162162
throw new NoResultException(sprintf('Could not find results for given query: %s', $query));
163-
} else {
164-
return $results;
165163
}
164+
165+
return $results;
166166
}
167167
}

tests/Geocoder/Tests/Provider/MapQuestProviderTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ public function testGetGeocodedDataWithAddressGetsNullContent()
3636
$provider->getGeocodedData('10 avenue Gambetta, Paris, France');
3737
}
3838

39+
/**
40+
* @expectedException \Geocoder\Exception\NoResultException
41+
* @expectedExceptionMessage Could not find results for given query: http://open.mapquestapi.com/geocoding/v1/reverse?key=api_key&lat=123.000000&lng=456.000000
42+
*/
43+
public function testGetNotRelevantData()
44+
{
45+
$json = '{"results":[{"locations":[{"street":"","postalCode":"","adminArea5":"","adminArea4":"","adminArea3":"","adminArea1":""}]}]}';
46+
47+
$provider = new MapQuestProvider($this->getMockAdapterReturns($json), 'api_key');
48+
$provider->getReversedData(array(123, 456));
49+
}
50+
3951
public function testGetGeocodedDataWithRealAddress()
4052
{
4153
if (!isset($_SERVER['MAPQUEST_API_KEY'])) {

0 commit comments

Comments
 (0)