fix(appointment): resolve issue with reserved slots incorrectly shown as available
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user