1
+ <?php
2
+
3
+ namespace ProgrammatorDev \OpenWeatherMap \Test \Integration ;
4
+
5
+ use ProgrammatorDev \OpenWeatherMap \Entity \Location ;
6
+ use ProgrammatorDev \OpenWeatherMap \Test \AbstractTest ;
7
+ use ProgrammatorDev \OpenWeatherMap \Test \MockResponse ;
8
+ use ProgrammatorDev \OpenWeatherMap \Test \Util \TestExceptionsTrait ;
9
+ use ProgrammatorDev \OpenWeatherMap \Test \Util \TestResponsesTrait ;
10
+
11
+ class GeocodingResourceTest extends AbstractTest
12
+ {
13
+ use TestResponsesTrait;
14
+ use TestExceptionsTrait;
15
+
16
+ public static function provideCollectionResponseData (): \Generator
17
+ {
18
+ yield 'get by location name ' => [
19
+ Location::class,
20
+ MockResponse::GEOCODING_DIRECT ,
21
+ 'geocoding ' ,
22
+ 'getByLocationName ' ,
23
+ ['test ' ]
24
+ ];
25
+ yield 'get by coordinate ' => [
26
+ Location::class,
27
+ MockResponse::GEOCODING_REVERSE ,
28
+ 'geocoding ' ,
29
+ 'getByCoordinate ' ,
30
+ [50 , 50 ]
31
+ ];
32
+ }
33
+
34
+ public static function provideItemResponseData (): \Generator
35
+ {
36
+ yield 'get by zip code ' => [
37
+ Location::class,
38
+ MockResponse::GEOCODING_ZIP ,
39
+ 'geocoding ' ,
40
+ 'getByZipCode ' ,
41
+ ['1000-001 ' , 'pt ' ]
42
+ ];
43
+ }
44
+
45
+ public static function provideValidationExceptionData (): \Generator
46
+ {
47
+ yield 'get by location name, blank value ' => ['geocoding ' , 'getByLocationName ' , ['' ]];
48
+ yield 'get by location name, zero num results ' => ['geocoding ' , 'getByLocationName ' , ['test ' , 0 ]];
49
+ yield 'get by coordinate, latitude lower than -90 ' => ['geocoding ' , 'getByCoordinate ' , [-91 , 50 ]];
50
+ yield 'get by coordinate, latitude greater than 90 ' => ['geocoding ' , 'getByCoordinate ' , [91 , 50 ]];
51
+ yield 'get by coordinate, longitude lower than -180 ' => ['geocoding ' , 'getByCoordinate ' , [50 , -181 ]];
52
+ yield 'get by coordinate, longitude greater than 180 ' => ['geocoding ' , 'getByCoordinate ' , [50 , 181 ]];
53
+ yield 'get by coordinate, zero num results ' => ['geocoding ' , 'getByCoordinate ' , [50 , 50 , 0 ]];
54
+ yield 'get by zip code, blank zip code ' => ['geocoding ' , 'getByZipCode ' , ['' , 'pt ' ]];
55
+ yield 'get by zip code, blank country code ' => ['geocoding ' , 'getByZipCode ' , ['1000-001 ' , '' ]];
56
+ yield 'get by zip code, invalid country code ' => ['geocoding ' , 'getByZipCode ' , ['1000-001 ' , 'invalid ' ]];
57
+ }
58
+ }
0 commit comments