balikobot-api/tests/Functional/Services/Storage/RedisStorageStoreTest.php

63 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2025-01-26 21:17:23 +01:00
<?php
declare(strict_types=1);
namespace App\Tests\Functional\Services\Storage;
use App\DTO\GEOPoint;
use App\DTO\WeatherAtTimePoint;
use App\Services\Storage\RedisStorageStore;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class RedisStorageStoreTest extends KernelTestCase
{
public function setUp(): void
{
$this->bootKernel();
}
public function testStoreAndReceiveData(): void
{
$dateTime = new \DateTime();
$dateTime->setTime(0, 0);
$tomorrowDateTime = \DateTime::createFromInterface($dateTime);
$tomorrowDateTime->add(new \DateInterval('P1D'));
$weatherAtTimePoints = [
new WeatherAtTimePoint(
$dateTime,
10,
-10,
1
),
new WeatherAtTimePoint(
$tomorrowDateTime,
10,
-10,
1
)
];
/**
* @var RedisStorageStore $redisStorage
*/
$redisStorage = $this->getContainer()->get(RedisStorageStore::class);
$redisStorage->storeWeatherForPointByDay(
new GEOPoint(
24,
24
),
$weatherAtTimePoints
);
$data = $redisStorage->receiveWeatherForPointByDay(
new GEOPoint(
24,
24
),
$weatherAtTimePoints[0]->date,
$weatherAtTimePoints[1]->date,
);
$this->assertEquals($weatherAtTimePoints, $data);
}
}