feat(appointments): only doctors with a weekly schedule get a tab
my/clinic-doctors now reports has_schedule per doctor, and the appointments page builds tabs from it. A doctor with no working days had a tab that could only ever show an empty timeline. The flag is resolved with one query for the whole list rather than one per doctor. Clinic owners now read this authenticated endpoint too instead of the public clinic doctor-list, which is where the flag lives; admin keeps the public list and, with no flag present, hides nobody. Also repairs fallout from making the resource supervisor mandatory: four test classes build resources through their own helpers and were failing with 422. The supervisorFor helper moved to ApiTestCase so all domains share one, rather than copying it per suite. Full backend suite is green again (1306 tests) — the previous commit only ran tests/Resource and missed this. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,8 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
* users and issue JWTs so tests can hit authenticated /api and /oauth endpoints.
|
||||
* Runs against the dedicated db_test database (see .env.test / doctrine when@test).
|
||||
*/
|
||||
use App\Doctor\Entity\DoctorAddress;
|
||||
|
||||
abstract class ApiTestCase extends WebTestCase
|
||||
{
|
||||
/**
|
||||
@@ -255,4 +257,32 @@ abstract class ApiTestCase extends WebTestCase
|
||||
|
||||
return array_sum(array_map('count', $holder->getData()));
|
||||
}
|
||||
/**
|
||||
* پزشکِ ناظرِ محیطِ همین آدرس — از وقتی ناظر روی منبع الزامی شد، هر ساختِ منبع
|
||||
* یکی لازم دارد. برای کلینیک یک پزشک عضو ساخته میشود و برای مطب، خودِ پزشک.
|
||||
*/
|
||||
protected function supervisorFor(DoctorAddress $address): Doctor
|
||||
{
|
||||
if ($address->tenantEntityType() === 'doctor') {
|
||||
return $this->em->getRepository(Doctor::class)->find($address->tenantEntityId());
|
||||
}
|
||||
|
||||
$clinic = $this->em->getRepository(Clinic::class)->find($address->tenantEntityId());
|
||||
|
||||
foreach ($clinic->getDoctors() as $existing) {
|
||||
return $existing;
|
||||
}
|
||||
|
||||
$user = $this->createUser(['ROLE_USER', 'ROLE_DOCTOR']);
|
||||
$doctor = new Doctor($user, 'پزشک ناظر');
|
||||
$doctor->setMobileNumber($user->getMobileNumber());
|
||||
$this->em->persist($doctor);
|
||||
$this->em->flush();
|
||||
|
||||
$clinic->getDoctors()->add($doctor);
|
||||
$this->em->flush();
|
||||
|
||||
return $doctor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user