2525use Geocoder \Query \ReverseQuery ;
2626use Http \Discovery \Psr18ClientDiscovery ;
2727use Nyholm \Psr7 \Response ;
28+ use PHPUnit \Framework \Attributes \DataProvider ;
2829use PHPUnit \Framework \MockObject \MockObject ;
2930use PHPUnit \Framework \TestCase ;
3031use 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 ' ];
0 commit comments