From f5d712d7e4b93c29bead0b1a8c00af8d7f978533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Beli=C3=ABn?= Date: Sat, 19 Dec 2020 10:41:04 +0100 Subject: [PATCH] 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 --- Tests/CountryInfoTest.php | 4 +- Tests/GeonamesTest.php | 146 +++++++++++++++++++------------------- composer.json | 2 +- 3 files changed, 75 insertions(+), 77 deletions(-) diff --git a/Tests/CountryInfoTest.php b/Tests/CountryInfoTest.php index a877233..3a8de4e 100644 --- a/Tests/CountryInfoTest.php +++ b/Tests/CountryInfoTest.php @@ -32,7 +32,7 @@ public function testCountryInfoWithOneCountry() $provider = new Geonames($this->getHttpClient($_SERVER['GEONAMES_USERNAME']), $_SERVER['GEONAMES_USERNAME']); $results = $provider->getCountryInfo('IN'); - $this->assertInternalType('array', $results); + $this->assertIsArray($results); $this->assertEquals(1, count($results)); /* @var CountryInfo $result */ @@ -42,7 +42,7 @@ public function testCountryInfoWithOneCountry() $this->assertInstanceOf('Geocoder\Model\Bounds', $result->getBounds()); $this->assertEquals('AS', $result->getContinent()); $this->assertEquals('New Delhi', $result->getCapital()); - $this->assertInternalType('array', $result->getLanguages()); + $this->assertIsArray($result->getLanguages()); $this->assertEquals(1269750, $result->getGeonameId()); $this->assertEquals('IND', $result->getIsoAlpha3()); $this->assertEquals('IN', $result->getFipsCode()); diff --git a/Tests/GeonamesTest.php b/Tests/GeonamesTest.php index 305543e..4faa96e 100644 --- a/Tests/GeonamesTest.php +++ b/Tests/GeonamesTest.php @@ -33,22 +33,20 @@ public function testGetName() $this->assertEquals('geonames', $provider->getName()); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Geonames provider does not support IP addresses. - */ public function testGeocodeWithLocalhostIPv4() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Geonames provider does not support IP addresses.'); + $provider = new Geonames($this->getMockedHttpClient(), 'username'); $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); } - /** - * @expectedException \Geocoder\Exception\UnsupportedOperation - * @expectedExceptionMessage The Geonames provider does not support IP addresses. - */ public function testGeocodeWithLocalhostIPv6() { + $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); + $this->expectExceptionMessage('The Geonames provider does not support IP addresses.'); + $provider = new Geonames($this->getMockedHttpClient(), 'username'); $provider->geocodeQuery(GeocodeQuery::create('::1')); } @@ -82,8 +80,8 @@ public function testGeocodeWithRealPlace() /** @var GeonamesAddress $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.49957, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.16359, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.49957, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.16359, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('United Kingdom', $result->getCountry()->getName()); $this->assertEquals('GB', $result->getCountry()->getCode()); $this->assertEquals('Europe/London', $result->getTimezone()); @@ -112,13 +110,13 @@ public function testGeocodeWithMultipleRealPlaces() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.508528775863, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.12574195861816, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.508528775863, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.12574195861816, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(51.151689398345, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-0.70360885396019, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(51.865368153381, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(0.45212493672386, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(51.151689398345, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-0.70360885396019, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(51.865368153381, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(0.45212493672386, $result->getBounds()->getEast(), 0.01); $this->assertEquals('London', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Greater London', $result->getAdminLevels()->get(2)->getName()); @@ -130,13 +128,13 @@ public function testGeocodeWithMultipleRealPlaces() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(-33.015285093464, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(27.911624908447, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(-33.015285093464, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(27.911624908447, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(-33.104996458003, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(27.804746435655, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(-32.925573728925, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(28.018503381239, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(-33.104996458003, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(27.804746435655, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(-32.925573728925, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(28.018503381239, $result->getBounds()->getEast(), 0.01); $this->assertEquals('East London', $result->getLocality()); $this->assertCount(3, $result->getAdminLevels()); $this->assertEquals('Buffalo City', $result->getAdminLevels()->get(3)->getName()); @@ -149,13 +147,13 @@ public function testGeocodeWithMultipleRealPlaces() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.512788890295, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.091838836669922, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.512788890295, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.091838836669922, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(51.155949512764, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-0.66976046752962, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(51.869628267826, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(0.48608279418978, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(51.155949512764, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-0.66976046752962, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(51.869628267826, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(0.48608279418978, $result->getBounds()->getEast(), 0.01); $this->assertEquals('City of London', $result->getLocality()); $this->assertCount(3, $result->getAdminLevels()); $this->assertEquals('City of London', $result->getAdminLevels()->get(3)->getName()); @@ -168,13 +166,13 @@ public function testGeocodeWithMultipleRealPlaces() /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(42.983389283, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-81.233042387, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(42.983389283, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-81.233042387, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(42.907075642763, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-81.337489676463, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(43.059702923237, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(-81.128595097537, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(42.907075642763, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-81.337489676463, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(43.059702923237, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(-81.128595097537, $result->getBounds()->getEast(), 0.01); $this->assertEquals('London', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); $this->assertEquals('Ontario', $result->getAdminLevels()->get(1)->getName()); @@ -185,13 +183,13 @@ public function testGeocodeWithMultipleRealPlaces() /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(41.3556539, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-72.0995209, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(41.3556539, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-72.0995209, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(41.334087887904, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-72.128261254846, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(41.377219912096, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(-72.070780545154, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(41.334087887904, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-72.128261254846, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(41.377219912096, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(-72.070780545154, $result->getBounds()->getEast(), 0.01); $this->assertEquals('New London', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('New London County', $result->getAdminLevels()->get(2)->getName()); @@ -216,13 +214,13 @@ public function testGeocodeWithMultipleRealPlacesWithLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.50853, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.12574, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.50853, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.12574, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(51.15169, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-0.70361, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(51.86537, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(0.45212, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(51.15169, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-0.70361, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(51.86537, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(0.45212, $result->getBounds()->getEast(), 0.01); $this->assertEquals('Londra', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Greater London', $result->getAdminLevels()->get(2)->getName()); @@ -234,13 +232,13 @@ public function testGeocodeWithMultipleRealPlacesWithLocale() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(-33.015285093464, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(27.911624908447, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(-33.015285093464, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(27.911624908447, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(-33.104996458003, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(27.804746435655, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(-32.925573728925, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(28.018503381239, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(-33.104996458003, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(27.804746435655, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(-32.925573728925, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(28.018503381239, $result->getBounds()->getEast(), 0.01); $this->assertEquals('East London', $result->getLocality()); $this->assertCount(3, $result->getAdminLevels()); $this->assertEquals('Buffalo City', $result->getAdminLevels()->get(3)->getName()); @@ -253,13 +251,13 @@ public function testGeocodeWithMultipleRealPlacesWithLocale() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.512788890295, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.091838836669922, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.512788890295, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.091838836669922, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(51.155949512764, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-0.66976046752962, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(51.869628267826, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(0.48608279418978, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(51.155949512764, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-0.66976046752962, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(51.869628267826, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(0.48608279418978, $result->getBounds()->getEast(), 0.01); $this->assertEquals('Città di Londra', $result->getLocality()); $this->assertCount(3, $result->getAdminLevels()); $this->assertEquals('City of London', $result->getAdminLevels()->get(3)->getName()); @@ -272,13 +270,13 @@ public function testGeocodeWithMultipleRealPlacesWithLocale() /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(42.983389283, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-81.233042387, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(42.983389283, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-81.233042387, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(42.907075642763, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-81.337489676463, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(43.059702923237, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(-81.128595097537, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(42.907075642763, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-81.337489676463, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(43.059702923237, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(-81.128595097537, $result->getBounds()->getEast(), 0.01); $this->assertEquals('London', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); $this->assertEquals('Ontario', $result->getAdminLevels()->get(1)->getName()); @@ -289,13 +287,13 @@ public function testGeocodeWithMultipleRealPlacesWithLocale() /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(41.3556539, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-72.0995209, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(41.3556539, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-72.0995209, $result->getCoordinates()->getLongitude(), 0.01); $this->assertNotNull($result->getBounds()); - $this->assertEquals(41.334087887904, $result->getBounds()->getSouth(), '', 0.01); - $this->assertEquals(-72.128261254846, $result->getBounds()->getWest(), '', 0.01); - $this->assertEquals(41.377219912096, $result->getBounds()->getNorth(), '', 0.01); - $this->assertEquals(-72.070780545154, $result->getBounds()->getEast(), '', 0.01); + $this->assertEqualsWithDelta(41.334087887904, $result->getBounds()->getSouth(), 0.01); + $this->assertEqualsWithDelta(-72.128261254846, $result->getBounds()->getWest(), 0.01); + $this->assertEqualsWithDelta(41.377219912096, $result->getBounds()->getNorth(), 0.01); + $this->assertEqualsWithDelta(-72.070780545154, $result->getBounds()->getEast(), 0.01); $this->assertEquals('New London', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Contea di New London', $result->getAdminLevels()->get(2)->getName()); @@ -320,8 +318,8 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.50853, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.12574, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.50853, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.12574, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('London', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Greater London', $result->getAdminLevels()->get(2)->getName()); @@ -346,8 +344,8 @@ public function testReverseWithRealCoordinatesWithLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.50853, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(-0.12574, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEqualsWithDelta(51.50853, $result->getCoordinates()->getLatitude(), 0.01); + $this->assertEqualsWithDelta(-0.12574, $result->getCoordinates()->getLongitude(), 0.01); $this->assertEquals('Londra', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Greater London', $result->getAdminLevels()->get(2)->getName()); diff --git a/composer.json b/composer.json index 3a91c7a..3b0f2c4 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.3 || ^8.0", "geocoder-php/common-http": "^4.0", "willdurand/geocoder": "^4.0" },