Skip to content

Commit

Permalink
Enable PHP 8.0 support (#1102)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jbelien committed Dec 19, 2020
1 parent 8f0af07 commit 651abd1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 31 deletions.
52 changes: 22 additions & 30 deletions Tests/IpInfoDbTest.php
Expand Up @@ -25,12 +25,11 @@ protected function getCacheDir()
return __DIR__.'/.cached_responses';
}

/**
* @expectedException \Geocoder\Exception\InvalidArgument
* @expectedExceptionMessage Invalid precision value "foo" (allowed values: "city", "country").
*/
public function testConstructWithInvalidPrecision()
{
$this->expectException(\Geocoder\Exception\InvalidArgument::class);
$this->expectExceptionMessage('Invalid precision value "foo" (allowed values: "city", "country").');

new IpInfoDb($this->getMockedHttpClient(), 'api_key', 'foo');
}

Expand All @@ -40,22 +39,20 @@ public function testGetName()
$this->assertEquals('ip_info_db', $provider->getName());
}

/**
* @expectedException \Geocoder\Exception\UnsupportedOperation
* @expectedExceptionMessage The IpInfoDb provider does not support street addresses, only IPv4 addresses.
*/
public function testGeocodeWithRandomString()
{
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
$this->expectExceptionMessage('The IpInfoDb provider does not support street addresses, only IPv4 addresses.');

$provider = new IpInfoDb($this->getMockedHttpClient(), 'api_key');
$provider->geocodeQuery(GeocodeQuery::create('foobar'));
}

/**
* @expectedException \Geocoder\Exception\UnsupportedOperation
* @expectedExceptionMessage The IpInfoDb provider does not support street addresses, only IPv4 addresses.
*/
public function testGeocodeWithAddress()
{
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
$this->expectExceptionMessage('The IpInfoDb provider does not support street addresses, only IPv4 addresses.');

$provider = new IpInfoDb($this->getMockedHttpClient(), 'api_key');
$provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France'));
}
Expand All @@ -81,30 +78,27 @@ public function testGeocodeWithLocalhostIPv4()
$this->assertEquals('localhost', $result->getCountry()->getName());
}

/**
* @expectedException \Geocoder\Exception\UnsupportedOperation
* @expectedExceptionMessage The IpInfoDb provider does not support IPv6 addresses, only IPv4 addresses.
*/
public function testGeocodeWithLocalhostIPv6()
{
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
$this->expectExceptionMessage('The IpInfoDb provider does not support IPv6 addresses, only IPv4 addresses.');

$provider = new IpInfoDb($this->getMockedHttpClient(), 'api_key');
$provider->geocodeQuery(GeocodeQuery::create('::1'));
}

/**
* @expectedException \Geocoder\Exception\InvalidServerResponse
*/
public function testGeocodeWithRealIPv4GetsNullContent()
{
$this->expectException(\Geocoder\Exception\InvalidServerResponse::class);

$provider = new IpInfoDb($this->getMockedHttpClient(), 'api_key');
$provider->geocodeQuery(GeocodeQuery::create('74.125.45.100'));
}

/**
* @expectedException \Geocoder\Exception\InvalidServerResponse
*/
public function testGeocodeWithRealIPv4GetsEmptyContent()
{
$this->expectException(\Geocoder\Exception\InvalidServerResponse::class);

$provider = new IpInfoDb($this->getMockedHttpClient(), 'api_key');
$provider->geocodeQuery(GeocodeQuery::create('74.125.45.100'));
}
Expand Down Expand Up @@ -135,12 +129,11 @@ public function testGeocodeWithRealIPv4()
$this->assertEquals('America/New_York', $result->getTimezone());
}

/**
* @expectedException \Geocoder\Exception\UnsupportedOperation
* @expectedExceptionMessage The IpInfoDb provider does not support IPv6 addresses, only IPv4 addresses.
*/
public function testGeocodeWithRealIPv6()
{
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
$this->expectExceptionMessage('The IpInfoDb provider does not support IPv6 addresses, only IPv4 addresses.');

if (!isset($_SERVER['IPINFODB_API_KEY'])) {
$this->markTestSkipped('You need to configure the IPINFODB_API_KEY value in phpunit.xml');
}
Expand Down Expand Up @@ -177,12 +170,11 @@ public function testGetGeocodedDataWithCountryPrecision()
$this->assertNull($result->getTimezone());
}

/**
* @expectedException \Geocoder\Exception\UnsupportedOperation
* @expectedExceptionMessage The IpInfoDb provider is not able to do reverse geocoding.
*/
public function testReverse()
{
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
$this->expectExceptionMessage('The IpInfoDb provider is not able to do reverse geocoding.');

$provider = new IpInfoDb($this->getMockedHttpClient(), 'api_key');
$provider->reverseQuery(ReverseQuery::fromCoordinates(0, 0));
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -12,7 +12,7 @@
}
],
"require": {
"php": "^7.2",
"php": "^7.3 || ^8.0",
"geocoder-php/common-http": "^4.0",
"willdurand/geocoder": "^4.0"
},
Expand Down

0 comments on commit 651abd1

Please sign in to comment.