Skip to content

Commit 82f7bbf

Browse files
committed
Fix OpenCage, IpInfoDb and BingMaps tests
1 parent 3578799 commit 82f7bbf

File tree

7 files changed

+10
-16
lines changed

7 files changed

+10
-16
lines changed

phpunit.xml.dist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020
<!-- API Keys -->
2121
<!-- <server name="IPINFODB_API_KEY" value="YOUR_API_KEY" /> -->
2222
<!-- <server name="BINGMAPS_API_KEY" value="YOUR_API_KEY" /> -->
23-
<!-- <server name="IGN_WEB_API_KEY" value="YOUR_API_KEY" /> -->
2423
<!-- <server name="GEOIPS_API_KEY" value="YOUR_API_KEY" /> -->
2524
<!-- <server name="MAXMIND_API_KEY" value="YOUR_API_KEY" /> -->
2625
<!-- <server name="MAPQUEST_API_KEY" value="YOUR_API_KEY" /> -->
2726
<!-- <server name="GEONAMES_USERNAME" value="YOUR_USERNAME" /> -->
28-
<!-- <server name="BAIDU_API_KEY" value="YOUR_API_KEY" /> -->
2927
<!-- <server name="TOMTOM_GEOCODING_KEY" value="YOUR_GEOCODING_KEY" /> -->
3028
<!-- <server name="TOMTOM_MAP_KEY" value="YOUR_MAP_KEY" /> -->
3129
<!-- <server name="GOOGLE_GEOCODING_KEY" value="YOUR_GEOCODING_KEY" /> -->

src/Geocoder/Provider/IpInfoDb.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function geocode($address)
5656

5757
// This API does not support IPv6
5858
if (filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
59-
throw new UnsupportedOperation('The IpInfoDb provider does not support IPv6 addresses.');
59+
throw new UnsupportedOperation('The IpInfoDb provider does not support IPv6 addresses, only IPv4 addresses.');
6060
}
6161

6262
if ('127.0.0.1' === $address) {

src/Geocoder/Provider/OpenCage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private function executeQuery($query)
153153
$results[] = array_merge($this->getDefaults(), array(
154154
'latitude' => $location['geometry']['lat'],
155155
'longitude' => $location['geometry']['lng'],
156-
'bounds' => $bounds ?: null,
156+
'bounds' => $bounds ?: [],
157157
'streetNumber' => isset($comp['house_number']) ? $comp['house_number'] : null,
158158
'streetName' => isset($comp['road'] ) ? $comp['road'] : null,
159159
'subLocality' => isset($comp['suburb'] ) ? $comp['suburb'] : null,

tests/Geocoder/Tests/CachedResponseAdapter.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,18 @@ protected function doSend(InternalRequestInterface $internalRequest)
4141

4242
if ($this->useCache && is_file($file) && is_readable($file)) {
4343
$content = unserialize(file_get_contents($file));
44-
$body = new StringStream($content);
44+
$body = new StringStream($content);
4545

4646
$response = $this->adapter->getConfiguration()->getMessageFactory()->createResponse(
47-
200,
48-
'OK',
49-
'1.1',
50-
[],
51-
$body
47+
200, 'OK', '1.1', [], $body
5248
);
5349

5450
if (!empty($content)) {
5551
return $response;
5652
}
5753
}
5854

59-
$response = $this->adapter->get($internalRequest);
55+
$response = $this->adapter->get($internalRequest->getUrl());
6056

6157
if ($this->useCache) {
6258
file_put_contents($file, serialize((string) $response->getBody()));

tests/Geocoder/Tests/Provider/BingMapsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public function testReverseWithRealCoordinatesReturnsSingleResult()
301301
$this->assertNull($result->getStreetNumber());
302302
$this->assertEquals('10 Avenue Gambetta', $result->getStreetName());
303303
$this->assertEquals(75020, $result->getPostalCode());
304-
$this->assertEquals('20e Arrondissement', $result->getLocality());
304+
$this->assertEquals('Paris', $result->getLocality());
305305
$this->assertEquals('Paris', $result->getCounty()->getName());
306306
$this->assertEquals('IdF', $result->getRegion()->getName());
307307
$this->assertEquals('France', $result->getCountry()->getName());

tests/Geocoder/Tests/Provider/IpInfoDbTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function testGeocodeWithLocalhostIPv4()
8686

8787
/**
8888
* @expectedException \Geocoder\Exception\UnsupportedOperation
89-
* @expectedExceptionMessage The IpInfoDb provider does not support IPv6 addresses.
89+
* @expectedExceptionMessage The IpInfoDb provider does not support IPv6 addresses, only IPv4 addresses.
9090
*/
9191
public function testGeocodeWithLocalhostIPv6()
9292
{
@@ -136,7 +136,7 @@ public function testGeocodeWithRealIPv4()
136136
$this->assertEquals('CALIFORNIA', $result->getRegion()->getName());
137137
$this->assertEquals('UNITED STATES', $result->getCountry()->getName());
138138
$this->assertEquals('US', $result->getCountry()->getCode());
139-
$this->assertEquals('America/Denver', $result->getTimezone());
139+
$this->assertEquals('America/Los_Angeles', $result->getTimezone());
140140
}
141141

142142
/**

tests/Geocoder/Tests/TestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Geocoder\Model\AddressFactory;
66
use Ivory\HttpAdapter\HttpAdapterInterface;
7-
use Ivory\HttpAdapter\SocketHttpAdapter;
7+
use Ivory\HttpAdapter\CurlHttpAdapter;
88

99
/**
1010
* @author William Durand <[email protected]>
@@ -73,7 +73,7 @@ protected function getMockAdapterReturns($returnValue)
7373
*/
7474
protected function getAdapter()
7575
{
76-
return new CachedResponseAdapter(new SocketHttpAdapter(), $this->useCache());
76+
return new CachedResponseAdapter(new CurlHttpAdapter(), $this->useCache());
7777
}
7878

7979
/**

0 commit comments

Comments
 (0)