createMock(AccommodationPriceRepository::class)); $covered = $coverage->coveredDatesFor( [$this->price('2026-06-01', '2026-06-09')], new \DateTimeImmutable('2026-06-01'), new \DateTimeImmutable('2026-06-12'), ); // dateTo is the last night, so 2026-06-09 is still covered self::assertSame([ '2026-06-01', '2026-06-02', '2026-06-03', '2026-06-04', '2026-06-05', '2026-06-06', '2026-06-07', '2026-06-08', '2026-06-09', ], array_keys($covered)); } public function testGapBetweenPricePeriodsStaysUncovered(): void { $coverage = new AccommodationPriceCoverage($this->createMock(AccommodationPriceRepository::class)); $covered = $coverage->coveredDatesFor( [$this->price('2026-06-01', '2026-06-02'), $this->price('2026-06-05', '2026-06-06')], new \DateTimeImmutable('2026-06-01'), new \DateTimeImmutable('2026-06-06'), ); self::assertSame( ['2026-06-01', '2026-06-02', '2026-06-05', '2026-06-06'], array_keys($covered), ); } public function testNoPricesMeansNoCoverage(): void { $coverage = new AccommodationPriceCoverage($this->createMock(AccommodationPriceRepository::class)); $covered = $coverage->coveredDatesFor( [], new \DateTimeImmutable('2026-06-01'), new \DateTimeImmutable('2026-06-03'), ); self::assertSame([], $covered); } private function price(string $from, string $to): AccommodationPrice { $price = new AccommodationPrice(); $price->setDateFrom(new \DateTimeImmutable($from)); $price->setDateTo(new \DateTimeImmutable($to)); return $price; } }