Skip to content

Commit b2357a6

Browse files
committed
chore: refactored OpenWeatherMap tests
1 parent f607673 commit b2357a6

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

tests/OpenWeatherMapTest.php

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ProgrammatorDev\OpenWeatherMap\Test;
44

5+
use PHPUnit\Framework\Attributes\DataProvider;
56
use ProgrammatorDev\OpenWeatherMap\Config;
67
use ProgrammatorDev\OpenWeatherMap\Endpoint\AirPollutionEndpoint;
78
use ProgrammatorDev\OpenWeatherMap\Endpoint\GeocodingEndpoint;
@@ -10,28 +11,18 @@
1011

1112
class 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

Comments
 (0)