feat: delete orphaned future snapshots after xml sync

This commit is contained in:
Björn Fromme
2026-03-25 15:35:12 +01:00
parent facd91375c
commit bca3610cff
4 changed files with 84 additions and 0 deletions
@@ -450,6 +450,41 @@ class TravelSnapshotServiceTest extends TestCase
$this->assertSame(['processed' => 0, 'updated' => 0, 'failed' => 0], $result);
}
public function testPurgeOrphanedFutureSnapshotsReturnsZeroForEmptyList(): void
{
$this->snapshotRepository
->expects($this->once())
->method('deleteOrphanedFutureSnapshots')
->with([], $this->isInstanceOf(\DateTimeImmutable::class))
->willReturn(0);
$result = $this->service->purgeOrphanedFutureSnapshots([]);
$this->assertSame(0, $result);
}
public function testPurgeOrphanedFutureSnapshotsDelegatesWithCorrectArguments(): void
{
$activeIds = [100, 200, 300];
$this->snapshotRepository
->expects($this->once())
->method('deleteOrphanedFutureSnapshots')
->with(
$activeIds,
$this->callback(function (\DateTimeImmutable $date) {
$expected = new \DateTimeImmutable('today');
return abs($date->getTimestamp() - $expected->getTimestamp()) < 5;
})
)
->willReturn(3);
$result = $this->service->purgeOrphanedFutureSnapshots($activeIds);
$this->assertSame(3, $result);
}
public function testGenerateMappingBuildsCorrectStructure(): void
{
$hotel = new Hotel();