1
+ <?php
2
+
3
+ namespace Integration ;
4
+
5
+ use ProgrammatorDev \OpenWeatherMap \Entity \AirPollution \AirPollution ;
6
+ use ProgrammatorDev \OpenWeatherMap \Entity \AirPollution \AirPollutionCollection ;
7
+ use ProgrammatorDev \OpenWeatherMap \Test \AbstractTest ;
8
+ use ProgrammatorDev \OpenWeatherMap \Test \MockResponse ;
9
+ use ProgrammatorDev \OpenWeatherMap \Test \Util \TestValidationExceptionTrait ;
10
+ use ProgrammatorDev \OpenWeatherMap \Test \Util \TestItemResponseTrait ;
11
+
12
+ class AirPollutionResourceTest extends AbstractTest
13
+ {
14
+ use TestItemResponseTrait;
15
+ use TestValidationExceptionTrait;
16
+
17
+ public static function provideItemResponseData (): \Generator
18
+ {
19
+ yield 'get current ' => [
20
+ AirPollution::class,
21
+ MockResponse::AIR_POLLUTION_CURRENT ,
22
+ 'airPollution ' ,
23
+ 'getCurrent ' ,
24
+ [50 , 50 ]
25
+ ];
26
+ yield 'get forecast ' => [
27
+ AirPollutionCollection::class,
28
+ MockResponse::AIR_POLLUTION_FORECAST ,
29
+ 'airPollution ' ,
30
+ 'getForecast ' ,
31
+ [50 , 50 ]
32
+ ];
33
+ yield 'get history ' => [
34
+ AirPollutionCollection::class,
35
+ MockResponse::AIR_POLLUTION_HISTORY ,
36
+ 'airPollution ' ,
37
+ 'getHistory ' ,
38
+ [50 , 50 , new \DateTime ('-1 day ' ), new \DateTime ('now ' )]
39
+ ];
40
+ }
41
+
42
+ public static function provideValidationExceptionData (): \Generator
43
+ {
44
+ yield 'get current, latitude lower than -90 ' => ['airPollution ' , 'getCurrent ' , [-91 , 50 ]];
45
+ yield 'get current, latitude greater than 90 ' => ['airPollution ' , 'getCurrent ' , [91 , 50 ]];
46
+ yield 'get current, longitude lower than -180 ' => ['airPollution ' , 'getCurrent ' , [50 , -181 ]];
47
+ yield 'get current, longitude greater than 180 ' => ['airPollution ' , 'getCurrent ' , [50 , 181 ]];
48
+ yield 'get forecast, latitude lower than -90 ' => ['airPollution ' , 'getForecast ' , [-91 , 50 ]];
49
+ yield 'get forecast, latitude greater than 90 ' => ['airPollution ' , 'getForecast ' , [91 , 50 ]];
50
+ yield 'get forecast, longitude lower than -180 ' => ['airPollution ' , 'getForecast ' , [50 , -181 ]];
51
+ yield 'get forecast, longitude greater than 180 ' => ['airPollution ' , 'getForecast ' , [50 , 181 ]];
52
+ yield 'get history, latitude lower than -90 ' => ['airPollution ' , 'getHistory ' , [-91 , 50 , new \DateTime ('-1 day ' ), new \DateTime ('now ' )]];
53
+ yield 'get history, latitude greater than 90 ' => ['airPollution ' , 'getHistory ' , [91 , 50 , new \DateTime ('-1 day ' ), new \DateTime ('now ' )]];
54
+ yield 'get history, longitude lower than -180 ' => ['airPollution ' , 'getHistory ' , [50 , -181 , new \DateTime ('-1 day ' ), new \DateTime ('now ' )]];
55
+ yield 'get history, longitude greater than 180 ' => ['airPollution ' , 'getHistory ' , [50 , 181 , new \DateTime ('-1 day ' ), new \DateTime ('now ' )]];
56
+ yield 'get history, end date before start date ' => ['airPollution ' , 'getHistory ' , [50 , 50 , new \DateTime ('now ' ), new \DateTime ('-1 day ' )]];
57
+ }
58
+ }
0 commit comments