Skip to content

Commit 5c3c227

Browse files
committed
feat: add support for PHPUnit 10 and 11
1 parent c15d968 commit 5c3c227

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

src/ProviderIntegrationTest.php

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Geocoder\Query\ReverseQuery;
2626
use Http\Discovery\Psr18ClientDiscovery;
2727
use Nyholm\Psr7\Response;
28+
use PHPUnit\Framework\Attributes\DataProvider;
2829
use PHPUnit\Framework\MockObject\MockObject;
2930
use PHPUnit\Framework\TestCase;
3031
use Psr\Http\Client\ClientInterface;
@@ -40,11 +41,11 @@ abstract class ProviderIntegrationTest extends TestCase
4041
*/
4142
protected array $skippedTests = [];
4243

43-
protected bool $testAddress = true;
44-
protected bool $testReverse = true;
45-
protected bool $testIpv4 = true;
46-
protected bool $testIpv6 = true;
47-
protected bool $testHttpProvider = true;
44+
protected static bool $testAddress = true;
45+
protected static bool $testReverse = true;
46+
protected static bool $testIpv4 = true;
47+
protected static bool $testIpv6 = true;
48+
protected static bool $testHttpProvider = true;
4849

4950
/**
5051
* @return Provider that is used in the tests.
@@ -102,7 +103,7 @@ public function testGeocodeQuery(): void
102103
if (isset($this->skippedTests[__FUNCTION__])) {
103104
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
104105
}
105-
if (!$this->testAddress) {
106+
if (!self::$testAddress) {
106107
$this->markTestSkipped('Geocoding address is not supported by this provider');
107108
}
108109

@@ -132,7 +133,7 @@ public function testGeocodeQueryWithNoResults(): void
132133
if (isset($this->skippedTests[__FUNCTION__])) {
133134
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
134135
}
135-
if (!$this->testAddress) {
136+
if (!self::$testAddress) {
136137
$this->markTestSkipped('Geocoding address is not supported by this provider');
137138
}
138139

@@ -148,7 +149,7 @@ public function testReverseQuery(): void
148149
if (isset($this->skippedTests[__FUNCTION__])) {
149150
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
150151
}
151-
if (!$this->testReverse) {
152+
if (!self::$testReverse) {
152153
$this->markTestSkipped('Reverse geocoding address is not supported by this provider');
153154
}
154155

@@ -165,7 +166,7 @@ public function testReverseQueryWithNoResults(): void
165166
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
166167
}
167168

168-
if (!$this->testReverse) {
169+
if (!self::$testReverse) {
169170
$this->markTestSkipped('Reverse geocoding address is not supported by this provider');
170171
}
171172

@@ -181,7 +182,7 @@ public function testGeocodeIpv4(): void
181182
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
182183
}
183184

184-
if (!$this->testIpv4) {
185+
if (!self::$testIpv4) {
185186
$this->markTestSkipped('Geocoding IPv4 is not supported by this provider');
186187
}
187188

@@ -196,7 +197,7 @@ public function testGeocodeIpv6(): void
196197
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
197198
}
198199

199-
if (!$this->testIpv6) {
200+
if (!self::$testIpv6) {
200201
$this->markTestSkipped('Geocoding IPv6 is not supported by this provider');
201202
}
202203

@@ -213,6 +214,7 @@ public function testGeocodeIpv6(): void
213214
* @param ResponseInterface|null $response
214215
* @param string $message
215216
*/
217+
#[DataProvider('exceptionDataProvider')]
216218
public function testExceptions($query, string $exceptionClass, ResponseInterface $response = null, string $message = ''): void
217219
{
218220
if (isset($this->skippedTests[__FUNCTION__])) {
@@ -236,15 +238,15 @@ public function testExceptions($query, string $exceptionClass, ResponseInterface
236238
/**
237239
* @return array<array{GeocodeQuery|ReverseQuery, class-string<Exception>, Response, string}>
238240
*/
239-
public function exceptionDataProvider(): array
241+
public static function exceptionDataProvider(): array
240242
{
241243
$testData = [];
242244

243-
if (!$this->testHttpProvider) {
245+
if (!self::$testHttpProvider) {
244246
return $testData;
245247
}
246248

247-
if ($this->testAddress) {
249+
if (self::$testAddress) {
248250
$q = GeocodeQuery::create('foo');
249251
$testData[] = [$q, InvalidServerResponse::class, new Response(500), 'Server 500'];
250252
$testData[] = [$q, InvalidServerResponse::class, new Response(400), 'Server 400'];
@@ -253,7 +255,7 @@ public function exceptionDataProvider(): array
253255
$testData[] = [$q, InvalidServerResponse::class, new Response(200), 'Empty response'];
254256
}
255257

256-
if ($this->testReverse) {
258+
if (self::$testReverse) {
257259
$q = ReverseQuery::fromCoordinates(0, 0);
258260
$testData[] = [$q, InvalidServerResponse::class, new Response(500), 'Server 500'];
259261
$testData[] = [$q, InvalidServerResponse::class, new Response(400), 'Server 400'];
@@ -262,7 +264,7 @@ public function exceptionDataProvider(): array
262264
$testData[] = [$q, QuotaExceeded::class, new Response(429), 'Quota exceeded response'];
263265
}
264266

265-
if ($this->testIpv4) {
267+
if (self::$testIpv4) {
266268
$q = GeocodeQuery::create('123.123.123.123');
267269
$testData[] = [$q, InvalidServerResponse::class, new Response(500), 'Server 500'];
268270
$testData[] = [$q, InvalidServerResponse::class, new Response(400), 'Server 400'];
@@ -271,7 +273,7 @@ public function exceptionDataProvider(): array
271273
$testData[] = [$q, QuotaExceeded::class, new Response(429), 'Quota exceeded response'];
272274
}
273275

274-
if ($this->testIpv6) {
276+
if (self::$testIpv6) {
275277
$q = GeocodeQuery::create('2001:0db8:0000:0042:0000:8a2e:0370:7334');
276278
$testData[] = [$q, InvalidServerResponse::class, new Response(500), 'Server 500'];
277279
$testData[] = [$q, InvalidServerResponse::class, new Response(400), 'Server 400'];

tests/NominatimTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*/
2020
class NominatimTest extends ProviderIntegrationTest
2121
{
22-
protected bool $testIpv4 = false;
23-
protected bool $testIpv6 = false;
22+
protected static bool $testIpv4 = false;
23+
protected static bool $testIpv6 = false;
2424

2525
protected function createProvider(ClientInterface $httpClient)
2626
{

0 commit comments

Comments
 (0)