initital commit
This commit is contained in:
47
tests/Integration/OpenMeteo/OpenMeteoApiTest.php
Normal file
47
tests/Integration/OpenMeteo/OpenMeteoApiTest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Integration\OpenMeteo;
|
||||
|
||||
use App\DTO\GEOPoint;
|
||||
use App\Services\Remote\OpenMeteoService;
|
||||
use App\Utils\Weather\WeatherInterval;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
class OpenMeteoApiTest extends KernelTestCase
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
self::bootKernel();
|
||||
}
|
||||
|
||||
public function testOpenMetoReturnsDataForDaily(): void
|
||||
{
|
||||
/**
|
||||
* @var OpenMeteoService $openMeteoApi
|
||||
*/
|
||||
$openMeteoApi = $this->getContainer()->get(OpenMeteoService::class);
|
||||
$fromDate = new \DateTime();
|
||||
$toDate = \DateTime::createFromInterface($fromDate)->add(new \DateInterval('P1D'));
|
||||
$weather = $openMeteoApi->fetchWeather(
|
||||
$this->geoPointPrague(),
|
||||
WeatherInterval::DAILY,
|
||||
$fromDate,
|
||||
$toDate,
|
||||
);
|
||||
|
||||
$this->assertCount(2, $weather);
|
||||
$this->assertEquals($fromDate->format('Y-m-d'), $weather[0]->date->format('Y-m-d'));
|
||||
$this->assertEquals($toDate->format('Y-m-d'), $weather[1]->date->format('Y-m-d'));
|
||||
}
|
||||
|
||||
private function geoPointPrague(): GEOPoint
|
||||
{
|
||||
return new GEOPoint(
|
||||
50.073658,
|
||||
14.418540
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user