fix(appointment): resolve issue with reserved slots incorrectly shown as available

This commit is contained in:
hamed
2026-07-15 19:13:27 +03:30
parent de6fe1bd56
commit d91867bd63
5 changed files with 227 additions and 3 deletions
+35
View File
@@ -75,4 +75,39 @@ class SlotUniquenessTest extends ApiTestCase
$this->expectException(SlotTakenException::class);
$repo->bookAtomically($this->newBooking($doctor, $start));
}
/**
* Regression: a slot whose only booking has already been consumed (completed,
* no_show, …) must still read as taken in the availability view — otherwise the
* public site offers an occupied slot as free. isSlotTaken counts the broader
* SLOT_BLOCKING_STATUSES, not just live pending/confirmed.
*/
public function testConsumedBookingStillMarksSlotTaken(): void
{
$doctor = $this->makeDoctor();
$start = time() + 86_400;
$repo = $this->em->getRepository(Appointment::class);
$appt = $this->newBooking($doctor, $start);
$appt->transitionTo(Appointment::STATUS_CONFIRMED);
$appt->transitionTo(Appointment::STATUS_COMPLETED);
$this->em->persist($appt);
$this->em->flush();
$this->assertTrue($repo->isSlotTaken($doctor, $start, $start + 1_800));
}
public function testCancelledBookingLeavesSlotFreeForAvailability(): void
{
$doctor = $this->makeDoctor();
$start = time() + 86_400;
$repo = $this->em->getRepository(Appointment::class);
$appt = $this->newBooking($doctor, $start);
$appt->transitionTo(Appointment::STATUS_CANCELLED_BY_USER);
$this->em->persist($appt);
$this->em->flush();
$this->assertFalse($repo->isSlotTaken($doctor, $start, $start + 1_800));
}
}