Skip to content

Commit a6de18b

Browse files
committed
Fix tests
1 parent 918776d commit a6de18b

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/Geocoder/Provider/IGNOpenLSProvider.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ public function getGeocodedData($address)
7373

7474
$xml = new \SimpleXMLElement($content);
7575

76-
if (isset($xml->ErrorList->Error)) {
76+
if (isset($xml->ErrorList->Error) || null === $xml->Response->GeocodeResponse) {
7777
throw new NoResultException(sprintf('Could not execute query %s', $query));
7878
}
7979

80-
$numberOfGeocodedAddresses = (int) $xml->Response->GeocodeResponse->GeocodeResponseList['numberOfGeocodedAddresses'];
80+
$numberOfGeocodedAddresses = (int) $xml->Response
81+
->GeocodeResponse
82+
->GeocodeResponseList['numberOfGeocodedAddresses'];
8183

8284
if (isset($numberOfGeocodedAddresses) && 0 === $numberOfGeocodedAddresses) {
8385
throw new NoResultException(sprintf('Could not execute query %s', $query));

src/Geocoder/Provider/MapQuestProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ class MapQuestProvider extends AbstractProvider implements ProviderInterface
2222
/**
2323
* @var string
2424
*/
25-
const GEOCODE_ENDPOINT_NOKEY_URL = 'http://open.mapquestapi.com/geocoding/v1/address?location=%s&outFormat=json&maxResults=1&thumbMaps=false';
25+
const GEOCODE_ENDPOINT_NOKEY_URL = 'http://open.mapquestapi.com/geocoding/v1/address?location=%s&outFormat=json&maxResults=%d&thumbMaps=false';
2626

2727
/**
2828
* @var string
2929
*/
30-
const GEOCODE_ENDPOINT_URL = 'http://www.mapquestapi.com/geocoding/v1/address?location=%s&outFormat=json&maxResults=1&key=%s';
30+
const GEOCODE_ENDPOINT_URL = 'http://www.mapquestapi.com/geocoding/v1/address?location=%s&outFormat=json&maxResults=%d&key=%s';
3131

3232
/**
3333
* @var string
@@ -52,9 +52,9 @@ public function getGeocodedData($address)
5252
}
5353

5454
if (null === $this->apiKey) {
55-
$query = sprintf(self::GEOCODE_ENDPOINT_NOKEY_URL, urlencode($address));
55+
$query = sprintf(self::GEOCODE_ENDPOINT_NOKEY_URL, urlencode($address), $this->getMaxResults());
5656
} else {
57-
$query = sprintf(self::GEOCODE_ENDPOINT_URL, urlencode($address), $this->apiKey);
57+
$query = sprintf(self::GEOCODE_ENDPOINT_URL, urlencode($address), $this->getMaxResults(), $this->apiKey);
5858
}
5959

6060
return $this->executeQuery($query);

tests/Geocoder/Tests/Provider/MapQuestProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testGetGeocodedData()
2828

2929
/**
3030
* @expectedException Geocoder\Exception\NoResultException
31-
* @expectedExceptionMessage Could not find results for given query: http://www.mapquestapi.com/geocoding/v1/address?location=foobar&outFormat=json&maxResults=1&key=my-api-key
31+
* @expectedExceptionMessage Could not find results for given query: http://www.mapquestapi.com/geocoding/v1/address?location=foobar&outFormat=json&maxResults=5&key=my-api-key
3232
*/
3333
public function testGetGeocodedDataWithApiKey()
3434
{

0 commit comments

Comments
 (0)