Skip to content

Commit 02e3252

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 788ae6c commit 02e3252

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

Tests/IP2LocationTest.php

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,42 +31,38 @@ public function testGetName()
3131
$this->assertEquals('ip2location', $provider->getName());
3232
}
3333

34-
/**
35-
* @expectedException \Geocoder\Exception\UnsupportedOperation
36-
* @expectedExceptionMessage The IP2Location provider does not support street addresses, only IP addresses.
37-
*/
3834
public function testGeocodeWithRandomString()
3935
{
36+
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
37+
$this->expectExceptionMessage('The IP2Location provider does not support street addresses, only IP addresses.');
38+
4039
$provider = new IP2Location($this->getMockedHttpClient(), 'api_key');
4140
$provider->geocodeQuery(GeocodeQuery::create('foobar'));
4241
}
4342

44-
/**
45-
* @expectedException \Geocoder\Exception\UnsupportedOperation
46-
* @expectedExceptionMessage The IP2Location provider does not support street addresses, only IP addresses.
47-
*/
4843
public function testGeocodeWithAddress()
4944
{
45+
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
46+
$this->expectExceptionMessage('The IP2Location provider does not support street addresses, only IP addresses.');
47+
5048
$provider = new IP2Location($this->getMockedHttpClient(), 'api_key');
5149
$provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France'));
5250
}
5351

54-
/**
55-
* @expectedException \Geocoder\Exception\InvalidCredentials
56-
* @expectedExceptionMessage API Key provided is not valid.
57-
*/
5852
public function testGeocodeWithInvalidKey()
5953
{
54+
$this->expectException(\Geocoder\Exception\InvalidCredentials::class);
55+
$this->expectExceptionMessage('API Key provided is not valid.');
56+
6057
$provider = new IP2Location($this->getHttpClient('invalid_key'), 'api_key');
6158
$results = $provider->geocodeQuery(GeocodeQuery::create('74.125.45.100'));
6259
}
6360

64-
/**
65-
* @expectedException \Geocoder\Exception\UnsupportedOperation
66-
* @expectedExceptionMessage The IP2Location provider does not support street addresses, only IP addresses.
67-
*/
6861
public function testGeocodeWithInvalidIPAddress()
6962
{
63+
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
64+
$this->expectExceptionMessage('The IP2Location provider does not support street addresses, only IP addresses.');
65+
7066
$provider = new IP2Location($this->getMockedHttpClient(), 'api_key');
7167
$provider->geocodeQuery(GeocodeQuery::create('300.23.255.5'));
7268
}
@@ -86,8 +82,8 @@ public function testGeocodeWithRealIPv4()
8682
/** @var Location $result */
8783
$result = $results->first();
8884
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
89-
$this->assertEquals(36.154, $result->getCoordinates()->getLatitude(), '', 0.001);
90-
$this->assertEquals(-95.9928, $result->getCoordinates()->getLongitude(), '', 0.001);
85+
$this->assertEqualsWithDelta(36.154, $result->getCoordinates()->getLatitude(), 0.001);
86+
$this->assertEqualsWithDelta(-95.9928, $result->getCoordinates()->getLongitude(), 0.001);
9187
$this->assertEquals(74101, $result->getPostalCode());
9288
$this->assertEquals('Tulsa', $result->getLocality());
9389
$this->assertCount(1, $result->getAdminLevels());
@@ -111,8 +107,8 @@ public function testGeocodeWithRealIPv6()
111107
/** @var Location $result */
112108
$result = $results->first();
113109
$this->assertInstanceOf('\Geocoder\Model\Address', $result);
114-
$this->assertEquals(36.154, $result->getCoordinates()->getLatitude(), '', 0.001);
115-
$this->assertEquals(-95.9928, $result->getCoordinates()->getLongitude(), '', 0.001);
110+
$this->assertEqualsWithDelta(36.154, $result->getCoordinates()->getLatitude(), 0.001);
111+
$this->assertEqualsWithDelta(-95.9928, $result->getCoordinates()->getLongitude(), 0.001);
116112
$this->assertEquals(74101, $result->getPostalCode());
117113
$this->assertEquals('Tulsa', $result->getLocality());
118114
$this->assertCount(1, $result->getAdminLevels());
@@ -121,12 +117,11 @@ public function testGeocodeWithRealIPv6()
121117
$this->assertEquals('US', $result->getCountry()->getCode());
122118
}
123119

124-
/**
125-
* @expectedException \Geocoder\Exception\UnsupportedOperation
126-
* @expectedExceptionMessage The IP2Location provider is not able to do reverse geocoding.
127-
*/
128120
public function testReverse()
129121
{
122+
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
123+
$this->expectExceptionMessage('The IP2Location provider is not able to do reverse geocoding.');
124+
130125
$provider = new IP2Location($this->getMockedHttpClient(), 'api_key');
131126
$provider->reverseQuery(ReverseQuery::fromCoordinates(0, 0));
132127
}

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)