feat: add test for clinic owner viewing slots when online booking is disabled
This commit is contained in:
@@ -4,6 +4,8 @@ namespace App\Tests\Appointment;
|
||||
|
||||
use App\Appointment\Entity\WeeklySchedule;
|
||||
use App\Appointment\Service\SlotCalculatorService;
|
||||
use App\Auth\Entity\User;
|
||||
use App\Clinic\Entity\Clinic;
|
||||
use App\Doctor\Entity\Doctor;
|
||||
use App\Tests\ApiTestCase;
|
||||
|
||||
@@ -120,4 +122,50 @@ class OnlineBookingManagementTest extends ApiTestCase
|
||||
self::assertSame(200, $this->responseCode());
|
||||
self::assertSame([], $body['data']['sessions']);
|
||||
}
|
||||
|
||||
/**
|
||||
* سناریوی واقعیِ گزارششده: پزشک عضو کلینیک، نوبتدهی آنلاینِ کلینیک خاموش،
|
||||
* مالک کلینیک از پنل «نوبتها» با management=1 باید اسلاتها را ببیند.
|
||||
*/
|
||||
public function testClinicOwnerSeesClinicSlotsWhenBookingDisabled(): void
|
||||
{
|
||||
$doctorOwner = $this->createUser(['ROLE_DOCTOR']);
|
||||
$doctor = new Doctor($doctorOwner, 'دکتر احمدی');
|
||||
$this->em->persist($doctor);
|
||||
|
||||
$clinicOwner = $this->createUser(['ROLE_USER', 'ROLE_CLINIC']);
|
||||
$clinic = new Clinic($clinicOwner);
|
||||
$clinic->setName('کلینیک تخصصی نمونه');
|
||||
$clinic->getDoctors()->add($doctor);
|
||||
$this->em->persist($clinic);
|
||||
|
||||
$date = date('Y-m-d', strtotime('tomorrow'));
|
||||
$dayKey = (string)(((int) date('w', strtotime($date)) + 1) % 7);
|
||||
|
||||
// برنامهٔ نوبتدهی در محیط کلینیک با نوبتدهی آنلاینِ خاموش.
|
||||
$schedule = new WeeklySchedule($doctor, [
|
||||
$dayKey => ['sessions' => [[
|
||||
'active' => true, 'start_time' => '10:00', 'end_time' => '12:00',
|
||||
'duration_per_patient' => 30, 'location_id' => 1,
|
||||
]]],
|
||||
], $clinic);
|
||||
$schedule->setMeta(['online_booking_enabled' => false]);
|
||||
$this->em->persist($schedule);
|
||||
$this->em->flush();
|
||||
|
||||
$uri = sprintf(
|
||||
'/api/v1/appointment-slots?doctor_uuid=%s&date=%s&clinic_uuid=%s&management=1',
|
||||
$doctor->getUuid(), $date, $clinic->getUuid(),
|
||||
);
|
||||
|
||||
// مالک کلینیک → اسلات میبیند.
|
||||
$body = $this->authJson('GET', $uri, $clinicOwner);
|
||||
self::assertSame(200, $this->responseCode());
|
||||
self::assertNotSame([], $body['data']['sessions'], 'مالک کلینیک باید اسلاتهای محیط کلینیک را ببیند');
|
||||
|
||||
// بدون احراز → عمومی، خالی.
|
||||
$this->client->request('GET', $uri);
|
||||
$anon = json_decode($this->client->getResponse()->getContent(), true);
|
||||
self::assertSame([], $anon['data']['sessions']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user