Skip to content

Commit b4beec6

Browse files
authored
Enable PHP 8.0 support (#1102)
* Enable PHP 8.0 support * Add GitHub Actions * Upgrade php-http/curl-client + php-http/httplug * Upgrade PHPUnit * Drop PHP 7.2 support * Update GitHub Actions Remove PHP 7.2 * Update Travis CI Remove PHP 7.2 * Drop PHP 7.2 support
1 parent e7f3191 commit b4beec6

File tree

3 files changed

+48
-53
lines changed

3 files changed

+48
-53
lines changed

Tests/HereTest.php

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ public function testGeocodeWithRealAddress()
4949
/** @var Location $result */
5050
$result = $results->first();
5151
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
52-
$this->assertEquals(48.8653, $result->getCoordinates()->getLatitude(), '', 0.01);
53-
$this->assertEquals(2.39844, $result->getCoordinates()->getLongitude(), '', 0.01);
52+
$this->assertEqualsWithDelta(48.8653, $result->getCoordinates()->getLatitude(), 0.01);
53+
$this->assertEqualsWithDelta(2.39844, $result->getCoordinates()->getLongitude(), 0.01);
5454
$this->assertNotNull($result->getBounds());
55-
$this->assertEquals(48.8664242, $result->getBounds()->getSouth(), '', 0.01);
56-
$this->assertEquals(2.3967311, $result->getBounds()->getWest(), '', 0.01);
57-
$this->assertEquals(48.8641758, $result->getBounds()->getNorth(), '', 0.01);
58-
$this->assertEquals(2.4001489, $result->getBounds()->getEast(), '', 0.01);
55+
$this->assertEqualsWithDelta(48.8664242, $result->getBounds()->getSouth(), 0.01);
56+
$this->assertEqualsWithDelta(2.3967311, $result->getBounds()->getWest(), 0.01);
57+
$this->assertEqualsWithDelta(48.8641758, $result->getBounds()->getNorth(), 0.01);
58+
$this->assertEqualsWithDelta(2.4001489, $result->getBounds()->getEast(), 0.01);
5959
$this->assertEquals(10, $result->getStreetNumber());
6060

6161
$this->assertEquals('Avenue Gambetta', $result->getStreetName());
@@ -85,13 +85,13 @@ public function testGeocodeWithDefaultAdditionalData()
8585
$result = $results->first();
8686

8787
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
88-
$this->assertEquals(41.37854, $result->getCoordinates()->getLatitude(), '', 0.01);
89-
$this->assertEquals(2.01196, $result->getCoordinates()->getLongitude(), '', 0.01);
88+
$this->assertEqualsWithDelta(41.37854, $result->getCoordinates()->getLatitude(), 0.01);
89+
$this->assertEqualsWithDelta(2.01196, $result->getCoordinates()->getLongitude(), 0.01);
9090
$this->assertNotNull($result->getBounds());
91-
$this->assertEquals(41.36505, $result->getBounds()->getSouth(), '', 0.01);
92-
$this->assertEquals(1.99398, $result->getBounds()->getWest(), '', 0.01);
93-
$this->assertEquals(41.39203, $result->getBounds()->getNorth(), '', 0.01);
94-
$this->assertEquals(2.02994, $result->getBounds()->getEast(), '', 0.01);
91+
$this->assertEqualsWithDelta(41.36505, $result->getBounds()->getSouth(), 0.01);
92+
$this->assertEqualsWithDelta(1.99398, $result->getBounds()->getWest(), 0.01);
93+
$this->assertEqualsWithDelta(41.39203, $result->getBounds()->getNorth(), 0.01);
94+
$this->assertEqualsWithDelta(2.02994, $result->getBounds()->getEast(), 0.01);
9595

9696
$this->assertEquals('08690', $result->getPostalCode());
9797
$this->assertEquals('Sant Roc', $result->getSubLocality());
@@ -130,13 +130,13 @@ public function testGeocodeWithAdditionalData()
130130
/** @var Location $result */
131131
$result = $results->first();
132132
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
133-
$this->assertEquals(41.37854, $result->getCoordinates()->getLatitude(), '', 0.01);
134-
$this->assertEquals(2.01196, $result->getCoordinates()->getLongitude(), '', 0.01);
133+
$this->assertEqualsWithDelta(41.37854, $result->getCoordinates()->getLatitude(), 0.01);
134+
$this->assertEqualsWithDelta(2.01196, $result->getCoordinates()->getLongitude(), 0.01);
135135
$this->assertNotNull($result->getBounds());
136-
$this->assertEquals(41.36505, $result->getBounds()->getSouth(), '', 0.01);
137-
$this->assertEquals(1.99398, $result->getBounds()->getWest(), '', 0.01);
138-
$this->assertEquals(41.39203, $result->getBounds()->getNorth(), '', 0.01);
139-
$this->assertEquals(2.02994, $result->getBounds()->getEast(), '', 0.01);
136+
$this->assertEqualsWithDelta(41.36505, $result->getBounds()->getSouth(), 0.01);
137+
$this->assertEqualsWithDelta(1.99398, $result->getBounds()->getWest(), 0.01);
138+
$this->assertEqualsWithDelta(41.39203, $result->getBounds()->getNorth(), 0.01);
139+
$this->assertEqualsWithDelta(2.02994, $result->getBounds()->getEast(), 0.01);
140140

141141
$this->assertEquals('08690', $result->getPostalCode());
142142
$this->assertEquals('Sant Roc', $result->getSubLocality());
@@ -152,7 +152,7 @@ public function testGeocodeWithAdditionalData()
152152
$this->assertEquals('NT_TzyupfxmTFN0Rh1TXEMqSA', $result->getAdditionalDataValue('routing_locationId'));
153153
$this->assertEquals('address', $result->getAdditionalDataValue('routing_result_type'));
154154
$this->assertEquals('WKTShapeType', $result->getShapeValue('_type'));
155-
$this->assertRegexp('/^MULTIPOLYGON/', $result->getShapeValue('Value'));
155+
$this->assertMatchesRegularExpression('/^MULTIPOLYGON/', $result->getShapeValue('Value'));
156156
}
157157

158158
/**
@@ -281,13 +281,13 @@ public function testReverseWithRealCoordinates()
281281
/** @var Location $result */
282282
$result = $results->first();
283283
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
284-
$this->assertEquals(48.8632147, $result->getCoordinates()->getLatitude(), '', 0.001);
285-
$this->assertEquals(2.3887722, $result->getCoordinates()->getLongitude(), '', 0.001);
284+
$this->assertEqualsWithDelta(48.8632147, $result->getCoordinates()->getLatitude(), 0.001);
285+
$this->assertEqualsWithDelta(2.3887722, $result->getCoordinates()->getLongitude(), 0.001);
286286
$this->assertNotNull($result->getBounds());
287-
$this->assertEquals(48.86315, $result->getBounds()->getSouth(), '', 0.001);
288-
$this->assertEquals(2.38853, $result->getBounds()->getWest(), '', 0.001);
289-
$this->assertEquals(48.8632147, $result->getBounds()->getNorth(), '', 0.001);
290-
$this->assertEquals(2.38883, $result->getBounds()->getEast(), '', 0.001);
287+
$this->assertEqualsWithDelta(48.86315, $result->getBounds()->getSouth(), 0.001);
288+
$this->assertEqualsWithDelta(2.38853, $result->getBounds()->getWest(), 0.001);
289+
$this->assertEqualsWithDelta(48.8632147, $result->getBounds()->getNorth(), 0.001);
290+
$this->assertEqualsWithDelta(2.38883, $result->getBounds()->getEast(), 0.001);
291291
$this->assertEquals('Avenue Gambetta', $result->getStreetName());
292292
$this->assertEquals(75020, $result->getPostalCode());
293293
$this->assertEquals('Paris', $result->getLocality());
@@ -301,41 +301,37 @@ public function testGetName()
301301
$this->assertEquals('Here', $provider->getName());
302302
}
303303

304-
/**
305-
* @expectedException \Geocoder\Exception\InvalidServerResponse
306-
*/
307304
public function testGeocodeWithInvalidData()
308305
{
306+
$this->expectException(\Geocoder\Exception\InvalidServerResponse::class);
307+
309308
$provider = new Here($this->getMockedHttpClient(), 'appId', 'appCode');
310309
$provider->geocodeQuery(GeocodeQuery::create('foobar'));
311310
}
312311

313-
/**
314-
* @expectedException \Geocoder\Exception\UnsupportedOperation
315-
* @expectedExceptionMessage The Here provider does not support IP addresses, only street addresses.
316-
*/
317312
public function testGeocodeIpv4()
318313
{
314+
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
315+
$this->expectExceptionMessage('The Here provider does not support IP addresses, only street addresses.');
316+
319317
$provider = $this->getProvider();
320318
$provider->geocodeQuery(GeocodeQuery::create('127.0.0.1'));
321319
}
322320

323-
/**
324-
* @expectedException \Geocoder\Exception\UnsupportedOperation
325-
* @expectedExceptionMessage The Here provider does not support IP addresses, only street addresses.
326-
*/
327321
public function testGeocodeWithLocalhostIPv6()
328322
{
323+
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
324+
$this->expectExceptionMessage('The Here provider does not support IP addresses, only street addresses.');
325+
329326
$provider = $this->getProvider();
330327
$provider->geocodeQuery(GeocodeQuery::create('::1'));
331328
}
332329

333-
/**
334-
* @expectedException \Geocoder\Exception\InvalidCredentials
335-
* @expectedExceptionMessage Invalid or missing api key.
336-
*/
337330
public function testGeocodeInvalidApiKey()
338331
{
332+
$this->expectException(\Geocoder\Exception\InvalidCredentials::class);
333+
$this->expectExceptionMessage('Invalid or missing api key.');
334+
339335
$provider = new Here(
340336
$this->getMockedHttpClient(
341337
'{
@@ -350,12 +346,11 @@ public function testGeocodeInvalidApiKey()
350346
$provider->geocodeQuery(GeocodeQuery::create('New York'));
351347
}
352348

353-
/**
354-
* @expectedException \Geocoder\Exception\UnsupportedOperation
355-
* @expectedExceptionMessage The Here provider does not support IP addresses, only street addresses.
356-
*/
357349
public function testGeocodeWithRealIPv6()
358350
{
351+
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
352+
$this->expectExceptionMessage('The Here provider does not support IP addresses, only street addresses.');
353+
359354
$provider = $this->getProvider();
360355
$provider->geocodeQuery(GeocodeQuery::create('::ffff:88.188.221.14'));
361356
}

Tests/IntegrationTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ public function testGeocodeQuery()
9898

9999
// Check Downing Street
100100
$location = $result->first();
101-
$this->assertEquals(51.5033, $location->getCoordinates()->getLatitude(), 'Latitude should be in London', 0.1);
102-
$this->assertEquals(-0.1276, $location->getCoordinates()->getLongitude(), 'Longitude should be in London', 0.1);
103-
$this->assertContains('Downing', $location->getStreetName(), 'Street name should contain "Downing St"');
101+
$this->assertEqualsWithDelta(51.5033, $location->getCoordinates()->getLatitude(), 0.1, 'Latitude should be in London');
102+
$this->assertEqualsWithDelta(-0.1276, $location->getCoordinates()->getLongitude(), 0.1, 'Longitude should be in London');
103+
$this->assertStringContainsString('Downing', $location->getStreetName(), 'Street name should contain "Downing St"');
104104

105105
if (null !== $streetNumber = $location->getStreetNumber()) {
106-
$this->assertContains('10', $streetNumber, 'Street number should contain "10"');
106+
$this->assertStringContainsString('10', $streetNumber, 'Street number should contain "10"');
107107
}
108108
}
109109

@@ -123,12 +123,12 @@ public function testGeocodeQueryCIT()
123123

124124
// Check Downing Street
125125
$location = $result->first();
126-
$this->assertEquals(51.5033, $location->getCoordinates()->getLatitude(), 'Latitude should be in London', 0.1);
127-
$this->assertEquals(-0.1276, $location->getCoordinates()->getLongitude(), 'Longitude should be in London', 0.1);
128-
$this->assertContains('Downing', $location->getStreetName(), 'Street name should contain "Downing St"');
126+
$this->assertEqualsWithDelta(51.5033, $location->getCoordinates()->getLatitude(), 0.1, 'Latitude should be in London');
127+
$this->assertEqualsWithDelta(-0.1276, $location->getCoordinates()->getLongitude(), 0.1, 'Longitude should be in London');
128+
$this->assertStringContainsString('Downing', $location->getStreetName(), 'Street name should contain "Downing St"');
129129

130130
if (null !== $streetNumber = $location->getStreetNumber()) {
131-
$this->assertContains('10', $streetNumber, 'Street number should contain "10"');
131+
$this->assertStringContainsString('10', $streetNumber, 'Street number should contain "10"');
132132
}
133133
}
134134

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"require": {
15-
"php": "^7.2",
15+
"php": "^7.3 || ^8.0",
1616
"geocoder-php/common-http": "^4.0",
1717
"willdurand/geocoder": "^4.0"
1818
},

0 commit comments

Comments
 (0)