44
55use Nyholm \Psr7 \Response ;
66use PHPUnit \Framework \Attributes \DataProviderExternal ;
7+ use ProgrammatorDev \OpenWeatherMap \Endpoint \AirPollutionEndpoint ;
78use ProgrammatorDev \OpenWeatherMap \Entity \AirPollution \AirPollution ;
89use ProgrammatorDev \OpenWeatherMap \Entity \AirPollution \AirPollutionLocationList ;
910use ProgrammatorDev \OpenWeatherMap \Entity \AirPollution \AirQuality ;
1011use ProgrammatorDev \OpenWeatherMap \Entity \AirPollution \AirPollutionLocation ;
1112use ProgrammatorDev \OpenWeatherMap \Entity \Coordinate ;
12- use ProgrammatorDev \OpenWeatherMap \Entity \Location ;
1313use ProgrammatorDev \OpenWeatherMap \Test \DataProvider \InvalidParamDataProvider ;
1414
1515class AirPollutionEndpointTest extends AbstractTest
1616{
17+ // --- CURRENT ---
18+
1719 public function testAirPollutionGetCurrent ()
1820 {
1921 $ this ->mockHttpClient ->addResponse (
@@ -23,17 +25,19 @@ public function testAirPollutionGetCurrent()
2325 )
2426 );
2527
26- $ response = $ this ->getApi ()->getAirPollution ()->getCurrent (38.7077507 , - 9.1365919 );
28+ $ response = $ this ->givenApi ()->getAirPollution ()->getCurrent (50 , 50 );
2729 $ this ->assertCurrentResponse ($ response );
2830 }
2931
3032 #[DataProviderExternal(InvalidParamDataProvider::class, 'provideInvalidCoordinateData ' )]
3133 public function testAirPollutionGetCurrentWithInvalidCoordinate (float $ latitude , float $ longitude , string $ expectedException )
3234 {
3335 $ this ->expectException ($ expectedException );
34- $ this ->getApi ()->getAirPollution ()->getCurrent ($ latitude , $ longitude );
36+ $ this ->givenApi ()->getAirPollution ()->getCurrent ($ latitude , $ longitude );
3537 }
3638
39+ // --- FORECAST ---
40+
3741 public function testAirPollutionGetForecast ()
3842 {
3943 $ this ->mockHttpClient ->addResponse (
@@ -43,17 +47,19 @@ public function testAirPollutionGetForecast()
4347 )
4448 );
4549
46- $ response = $ this ->getApi ()->getAirPollution ()->getForecast (38.7077507 , - 9.1365919 );
50+ $ response = $ this ->givenApi ()->getAirPollution ()->getForecast (50 , 50 );
4751 $ this ->assertForecastResponse ($ response );
4852 }
4953
5054 #[DataProviderExternal(InvalidParamDataProvider::class, 'provideInvalidCoordinateData ' )]
5155 public function testAirPollutionGetForecastWithInvalidCoordinate (float $ latitude , float $ longitude , string $ expectedException )
5256 {
5357 $ this ->expectException ($ expectedException );
54- $ this ->getApi ()->getAirPollution ()->getForecast ($ latitude , $ longitude );
58+ $ this ->givenApi ()->getAirPollution ()->getForecast ($ latitude , $ longitude );
5559 }
5660
61+ // --- HISTORY ---
62+
5763 public function testAirPollutionGetHistory ()
5864 {
5965 $ this ->mockHttpClient ->addResponse (
@@ -65,9 +71,9 @@ public function testAirPollutionGetHistory()
6571
6672 $ utcTimezone = new \DateTimeZone ('UTC ' );
6773
68- $ response = $ this ->getApi ()->getAirPollution ()->getHistory (
69- 38.7077507 ,
70- - 9.1365919 ,
74+ $ response = $ this ->givenApi ()->getAirPollution ()->getHistory (
75+ 50 ,
76+ 50 ,
7177 new \DateTimeImmutable ('-5 days ' , $ utcTimezone ),
7278 new \DateTimeImmutable ('-4 days ' , $ utcTimezone )
7379 );
@@ -82,7 +88,7 @@ public function testAirPollutionGetHistoryWithInvalidCoordinate(float $latitude,
8288 $ startDate = new \DateTimeImmutable ('-5 days ' );
8389 $ endDate = new \DateTimeImmutable ('-4 days ' );
8490
85- $ this ->getApi ()->getAirPollution ()->getHistory ($ latitude , $ longitude , $ startDate , $ endDate );
91+ $ this ->givenApi ()->getAirPollution ()->getHistory ($ latitude , $ longitude , $ startDate , $ endDate );
8692 }
8793
8894 #[DataProviderExternal(InvalidParamDataProvider::class, 'provideInvalidPastDateData ' )]
@@ -92,9 +98,9 @@ public function testAirPollutionGetHistoryWithInvalidPastStartDate(
9298 )
9399 {
94100 $ this ->expectException ($ expectedException );
95- $ this ->getApi ()->getAirPollution ()->getHistory (
96- 38.7077507 ,
97- - 9.1365919 ,
101+ $ this ->givenApi ()->getAirPollution ()->getHistory (
102+ 50 ,
103+ 50 ,
98104 $ startDate ,
99105 new \DateTimeImmutable ('-5 days ' , new \DateTimeZone ('UTC ' ))
100106 );
@@ -107,9 +113,9 @@ public function testAirPollutionGetHistoryWithInvalidPastEndDate(
107113 )
108114 {
109115 $ this ->expectException ($ expectedException );
110- $ this ->getApi ()->getAirPollution ()->getHistory (
111- 38.7077507 ,
112- - 9.1365919 ,
116+ $ this ->givenApi ()->getAirPollution ()->getHistory (
117+ 50 ,
118+ 50 ,
113119 new \DateTimeImmutable ('-5 days ' , new \DateTimeZone ('UTC ' )),
114120 $ endDate
115121 );
@@ -123,9 +129,20 @@ public function testAirPollutionGetHistoryWithInvalidDateRange(
123129 )
124130 {
125131 $ this ->expectException ($ expectedException );
126- $ this ->getApi ()->getAirPollution ()->getHistory (38.7077507 , -9.1365919 , $ startDate , $ endDate );
132+ $ this ->givenApi ()->getAirPollution ()->getHistory (50 , 50 , $ startDate , $ endDate );
133+ }
134+
135+ // --- ASSERT METHODS EXIST ---
136+
137+ public function testAirPollutionMethodsExist ()
138+ {
139+ $ this ->assertSame (false , method_exists (AirPollutionEndpoint::class, 'withUnitSystem ' ));
140+ $ this ->assertSame (false , method_exists (AirPollutionEndpoint::class, 'withLanguage ' ));
141+ $ this ->assertSame (true , method_exists (AirPollutionEndpoint::class, 'withCacheTtl ' ));
127142 }
128143
144+ // --- ASSERT RESPONSES ---
145+
129146 private function assertCurrentResponse (AirPollutionLocation $ response ): void
130147 {
131148 $ this ->assertInstanceOf (AirPollutionLocation::class, $ response );
0 commit comments