22
33namespace ProgrammatorDev \OpenWeatherMap \Test ;
44
5+ use PHPUnit \Framework \Attributes \DataProvider ;
56use ProgrammatorDev \OpenWeatherMap \Config ;
67use ProgrammatorDev \OpenWeatherMap \Endpoint \AirPollutionEndpoint ;
78use ProgrammatorDev \OpenWeatherMap \Endpoint \GeocodingEndpoint ;
1011
1112class OpenWeatherMapTest extends AbstractTest
1213{
13- public function testOpenWeatherMapConfig ()
14+ #[DataProvider('provideMethodsData ' )]
15+ public function testOpenWeatherMapMethods (string $ instance , string $ methodName )
1416 {
15- $ this ->assertInstanceOf (Config::class , $ this ->givenApi ()->config ());
17+ $ this ->assertInstanceOf ($ instance , $ this ->givenApi ()->$ methodName ());
1618 }
1719
18- public function testOpenWeatherMapOneCall ()
20+ public static function provideMethodsData (): \ Generator
1921 {
20- $ this ->assertInstanceOf (OneCallEndpoint::class, $ this ->givenApi ()->oneCall ());
21- }
22-
23- public function testOpenWeatherMapWeather ()
24- {
25- $ this ->assertInstanceOf (WeatherEndpoint::class, $ this ->givenApi ()->weather ());
26- }
27-
28- public function testOpenWeatherMapAirPollution ()
29- {
30- $ this ->assertInstanceOf (AirPollutionEndpoint::class, $ this ->givenApi ()->airPollution ());
31- }
32-
33- public function testOpenWeatherMapGeocoding ()
34- {
35- $ this ->assertInstanceOf (GeocodingEndpoint::class, $ this ->givenApi ()->geocoding ());
22+ yield 'config ' => [Config::class, 'config ' ];
23+ yield 'air pollution ' => [AirPollutionEndpoint::class, 'airPollution ' ];
24+ yield 'geocoding ' => [GeocodingEndpoint::class, 'geocoding ' ];
25+ yield 'one call ' => [OneCallEndpoint::class, 'oneCall ' ];
26+ yield 'weather ' => [WeatherEndpoint::class, 'weather ' ];
3627 }
3728}
0 commit comments