Skip to content

Commit

Permalink
Merge pull request #6 from holtkamp/allow-php-8
Browse files Browse the repository at this point in the history
Allow php 8
  • Loading branch information
JaZo authored Jan 18, 2021
2 parents 8849bfd + efd90e9 commit dc227ac
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.phpunit.result.cache
/.idea
composer.lock
composer.phar
Expand Down
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
dist: trusty
language: php

php:
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0

## Cache composer
cache:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
],
"homepage": "/~https://github.com/swisnl/geocoder-php-nationaal-georegister-provider",
"require": {
"php": "^7.0",
"php": "^7.2 || ^8.0",
"ext-json": "*",
"geocoder-php/common-http": "^4.0",
"willdurand/geocoder": "^4.0"
},
"require-dev": {
"geocoder-php/provider-integration-tests": "^1.0",
"php-http/curl-client": "^1.7",
"phpunit/phpunit": "^6.0|^7.0"
"php-http/curl-client": "^2.0",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
},
"provide": {
"geocoder-php/provider-implementation": "1.0"
Expand Down
40 changes: 14 additions & 26 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="./vendor/autoload.php"
>
<php>
<server name="USE_CACHED_RESPONSES" value="true" />
</php>

<testsuites>
<testsuite name="Geocoder Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="./vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./src/</directory>
</include>
</coverage>
<php>
<server name="USE_CACHED_RESPONSES" value="true"/>
</php>
<testsuites>
<testsuite name="Geocoder Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
4 changes: 2 additions & 2 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ protected function createProvider(HttpClient $httpClient)
return new NationaalGeoregister($httpClient);
}

protected function getCacheDir()
protected function getCacheDir() : string
{
return __DIR__.'/.cached_responses';
}

protected function getApiKey()
protected function getApiKey() : ?string
{
return null;
}
Expand Down
40 changes: 19 additions & 21 deletions tests/NationaalGeoregisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,39 @@

class NationaalGeoregisterTest extends BaseTestCase
{
protected function getCacheDir()
protected function getCacheDir() : string
{
return __DIR__.'/.cached_responses';
}

public function testExtraOptionsCanBeSet()
public function testExtraOptionsCanBeSet() : void
{
$provider = new NationaalGeoregister($this->getMockedHttpClient(), ['ident' => 'true']);
$this->assertEquals(['ident' => 'true'], $provider->getOptions());
}

public function testBlacklistedOptionsCanNotBeSet()
public function testBlacklistedOptionsCanNotBeSet() : void
{
$provider = new NationaalGeoregister($this->getMockedHttpClient(), ['fl' => '*']);
$this->assertEquals([], $provider->getOptions());
}

public function testGetName()
public function testGetName() : void
{
$provider = new NationaalGeoregister($this->getMockedHttpClient());
$this->assertEquals('nationaal_georegister', $provider->getName());
}

/**
* @expectedException \Geocoder\Exception\UnsupportedOperation
* @expectedExceptionMessage The NationaalGeoregister provider does not support IP addresses.
*/
public function testGeocodeWithIPAddress()
public function testGeocodeWithIPAddress() : void
{
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
$this->expectExceptionMessage('The NationaalGeoregister provider does not support IP addresses.');

$provider = new NationaalGeoregister($this->getMockedHttpClient());
$provider->geocodeQuery(GeocodeQuery::create('8.8.8.8'));
}

public function testGeocodeWithShortPostalCode()
public function testGeocodeWithShortPostalCode() : void
{
$provider = new NationaalGeoregister($this->getHttpClient());
$results = $provider->geocodeQuery(GeocodeQuery::create('2312'));
Expand All @@ -71,7 +70,7 @@ public function testGeocodeWithShortPostalCode()
$this->assertEquals('nationaal_georegister', $result->getProvidedBy());
}

public function testGeocodeWithPostalCode()
public function testGeocodeWithPostalCode() : void
{
$provider = new NationaalGeoregister($this->getHttpClient());
$results = $provider->geocodeQuery(GeocodeQuery::create('2312 NR'));
Expand All @@ -82,8 +81,8 @@ public function testGeocodeWithPostalCode()
/** @var \Geocoder\Location $result */
$result = $results->first();
$this->assertInstanceOf(Address::class, $result);
$this->assertEquals(52.16416908, $result->getCoordinates()->getLatitude(), '', 0.001);
$this->assertEquals(4.49098397, $result->getCoordinates()->getLongitude(), '', 0.001);
$this->assertEqualsWithDelta(52.16416908, $result->getCoordinates()->getLatitude(), 0.001);
$this->assertEqualsWithDelta(4.49098397, $result->getCoordinates()->getLongitude(), 0.001);
$this->assertNull($result->getStreetNumber());
$this->assertEquals('3e Binnenvestgracht', $result->getStreetName());
$this->assertEquals('2312NR', $result->getPostalCode());
Expand All @@ -96,7 +95,7 @@ public function testGeocodeWithPostalCode()
$this->assertEquals('nationaal_georegister', $result->getProvidedBy());
}

public function testGeocodeWithPostalCodeAndStreetNumber()
public function testGeocodeWithPostalCodeAndStreetNumber() : void
{
$provider = new NationaalGeoregister($this->getHttpClient());
$results = $provider->geocodeQuery(GeocodeQuery::create('2312 NR, 23'));
Expand All @@ -121,7 +120,7 @@ public function testGeocodeWithPostalCodeAndStreetNumber()
$this->assertEquals('nationaal_georegister', $result->getProvidedBy());
}

public function testGeocodeWithStreetNameAndStreetNumber()
public function testGeocodeWithStreetNameAndStreetNumber() : void
{
$provider = new NationaalGeoregister($this->getHttpClient());
$results = $provider->geocodeQuery(GeocodeQuery::create('3e Binnenvestgracht 23'));
Expand All @@ -146,7 +145,7 @@ public function testGeocodeWithStreetNameAndStreetNumber()
$this->assertEquals('nationaal_georegister', $result->getProvidedBy());
}

public function testGeocodeWithStreetNameStreetNumberAndCity()
public function testGeocodeWithStreetNameStreetNumberAndCity() : void
{
$provider = new NationaalGeoregister($this->getHttpClient());
$results = $provider->geocodeQuery(GeocodeQuery::create('3e Binnenvestgracht 23, Leiden'));
Expand All @@ -171,7 +170,7 @@ public function testGeocodeWithStreetNameStreetNumberAndCity()
$this->assertEquals('nationaal_georegister', $result->getProvidedBy());
}

public function testReverse()
public function testReverse() : void
{
$provider = new NationaalGeoregister($this->getHttpClient());
$results = $provider->reverseQuery(ReverseQuery::fromCoordinates(52.16416908, 4.49098397));
Expand All @@ -196,11 +195,10 @@ public function testReverse()
$this->assertEquals('nationaal_georegister', $result->getProvidedBy());
}

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

$provider = new NationaalGeoregister($this->getMockedHttpClient());
$provider->geocodeQuery(GeocodeQuery::create('Lorem ipsum'));
}
Expand Down

0 comments on commit dc227ac

Please sign in to comment.