feat: sync contingents for TYPO3 calendar hotels
This commit is contained in:
1 parent
ec36b61275
commit
97c6330a9a
24 files changed
+1067
-180
No files matched your search
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace App\Tests\Service;
|
||||
|
||||
use App\BpnConnect\Model\ContingentStatus;
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Entity\Groups\ContingentDay;
|
||||
use App\Entity\Groups\ContingentSyncState;
|
||||
use App\Repository\Groups\ContingentDayRepository;
|
||||
@@ -31,7 +30,7 @@ class ContingentSnapshotReaderTest extends TestCase
|
||||
{
|
||||
$this->dayRepository = $this->createMock(ContingentDayRepository::class);
|
||||
|
||||
$this->syncStateRepository->method('findOneByAccommodation')->willReturn(null);
|
||||
$this->syncStateRepository->method('findOneByHotelCode')->willReturn(null);
|
||||
$this->dayRepository->expects(self::never())->method('findByHotelCodeAndDateRange');
|
||||
|
||||
self::assertNull($this->read());
|
||||
@@ -41,7 +40,7 @@ class ContingentSnapshotReaderTest extends TestCase
|
||||
{
|
||||
$this->dayRepository = $this->createMock(ContingentDayRepository::class);
|
||||
|
||||
$this->syncStateRepository->method('findOneByAccommodation')->willReturn($this->state('-7 hours'));
|
||||
$this->syncStateRepository->method('findOneByHotelCode')->willReturn($this->state('-7 hours'));
|
||||
$this->dayRepository->expects(self::never())->method('findByHotelCodeAndDateRange');
|
||||
|
||||
self::assertNull($this->read());
|
||||
@@ -49,7 +48,7 @@ class ContingentSnapshotReaderTest extends TestCase
|
||||
|
||||
public function testReturnsStatusesWhenRecentlySynced(): void
|
||||
{
|
||||
$this->syncStateRepository->method('findOneByAccommodation')->willReturn($this->state('-10 minutes'));
|
||||
$this->syncStateRepository->method('findOneByHotelCode')->willReturn($this->state('-10 minutes'));
|
||||
$this->dayRepository->method('findByHotelCodeAndDateRange')->willReturn([
|
||||
'2026-09-01' => $this->day(ContingentStatus::Ok),
|
||||
'2026-09-02' => $this->day(ContingentStatus::OnRequest),
|
||||
@@ -63,25 +62,39 @@ class ContingentSnapshotReaderTest extends TestCase
|
||||
|
||||
public function testStillUsableJustInsideTheStalenessWindow(): void
|
||||
{
|
||||
$this->syncStateRepository->method('findOneByAccommodation')->willReturn($this->state('-5 hours'));
|
||||
$this->syncStateRepository->method('findOneByHotelCode')->willReturn($this->state('-5 hours'));
|
||||
$this->dayRepository->method('findByHotelCodeAndDateRange')->willReturn([]);
|
||||
|
||||
self::assertSame([], $this->read());
|
||||
}
|
||||
|
||||
public function testReturnsNullForAnAccommodationWithoutACalendarCode(): void
|
||||
public function testReturnsNullForAnEmptyHotelCode(): void
|
||||
{
|
||||
$this->syncStateRepository = $this->createMock(ContingentSyncStateRepository::class);
|
||||
|
||||
$this->syncStateRepository->expects(self::never())->method('findOneByAccommodation');
|
||||
$this->syncStateRepository->expects(self::never())->method('findOneByHotelCode');
|
||||
|
||||
self::assertNull($this->read(new Accommodation()));
|
||||
self::assertNull($this->read(''));
|
||||
}
|
||||
|
||||
public function testIsCurrentMatchesWhatStatusesForServes(): void
|
||||
{
|
||||
$reader = new ContingentSnapshotReader(
|
||||
$this->dayRepository,
|
||||
$this->syncStateRepository,
|
||||
$this->createStub(LoggerInterface::class),
|
||||
);
|
||||
|
||||
self::assertFalse($reader->isCurrent(null));
|
||||
self::assertFalse($reader->isCurrent(new ContingentSyncState('HOTEL1')));
|
||||
self::assertFalse($reader->isCurrent($this->state('-7 hours')));
|
||||
self::assertTrue($reader->isCurrent($this->state('-5 hours')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, ContingentStatus>|null
|
||||
*/
|
||||
private function read(?Accommodation $accommodation = null): ?array
|
||||
private function read(string $hotelCode = 'HOTEL1'): ?array
|
||||
{
|
||||
$reader = new ContingentSnapshotReader(
|
||||
$this->dayRepository,
|
||||
@@ -90,7 +103,7 @@ class ContingentSnapshotReaderTest extends TestCase
|
||||
);
|
||||
|
||||
return $reader->statusesFor(
|
||||
$accommodation ?? (new Accommodation())->setCalendarCode('HOTEL1'),
|
||||
$hotelCode,
|
||||
new \DateTimeImmutable('2026-09-01'),
|
||||
new \DateTimeImmutable('2026-09-03'),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user