refactor(branch): remove the branch domain, keep the address
Branches and rooms are not part of the resource-first product: a room is a
resource like any other, and the only thing the branch pages still managed —
opening hours — duplicated the resource's own shift.
What could not go is the address. Every appointment carries address_id (75 of
75 rows), the public booking site reads /clinic-pro/doctor-address/{id}, and a
resource derives its tenant pair from the address it belongs to. So
DoctorAddress stays as an invisible anchor with no page and no menu entry, and
GET /api/v1/addresses replaces GET /api/v1/branches for the forms that still
need to say "where".
BranchResolver was likewise not a branch feature. doctor_addresses is a global
table, so TenantFilter does not cover it and eight callers across booking,
availability, pricing and the catalog went through this resolver to avoid
leaking another clinic's address. It moved to Doctor\Service\AddressResolver
rather than dying with the domain.
The availability engine loses one layer: a resource's real hours were the
branch hours intersected with its shift, and are now the shift alone. That is
the single behavioural change, and the three tests that asserted the old
contract are replaced by one that states the new one.
Rooms already had a resource row each; the migration drops only the bridge
back to `rooms`, and drops it before the table — that foreign key is ON DELETE
CASCADE and the other order would take the resources, and their appointments,
with it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -57,30 +57,12 @@ class BackfillResourceTest extends ResourceTestCase
|
||||
public function testDryRunWritesNothing(): void
|
||||
{
|
||||
[, , $address] = $this->clinicWithAddress();
|
||||
$room = $this->room($address, 'اتاق دراِیران');
|
||||
$staff = $this->staff($address, 'اپراتور دراِیران');
|
||||
|
||||
$output = $this->runBackfill(false, $this->pairOf($address));
|
||||
|
||||
self::assertStringContainsString('Dry run', $output);
|
||||
self::assertNull($this->resources()->findForSubject($room));
|
||||
}
|
||||
|
||||
public function testRoomBecomesAResourceCarryingItsCapacity(): void
|
||||
{
|
||||
[, , $address] = $this->clinicWithAddress();
|
||||
$room = $this->room($address, 'اتاق تزریق سهتخته', 3);
|
||||
|
||||
$this->runBackfill(true, $this->pairOf($address));
|
||||
$this->em->clear();
|
||||
|
||||
$resource = $this->resources()->findForSubject(
|
||||
$this->em->getRepository(\App\Branch\Entity\Room::class)->find($room->getId())
|
||||
);
|
||||
|
||||
self::assertNotNull($resource);
|
||||
self::assertSame(3, $resource->getCapacity(), 'اتاق سهتخته یک منبع با ظرفیت ۳ است، نه سه منبع');
|
||||
self::assertSame(ResourceType::CODE_ROOM, $resource->getType()->getCode());
|
||||
self::assertTrue($resource->getType()->isSystem());
|
||||
self::assertNull($this->resources()->findForSubject($staff));
|
||||
}
|
||||
|
||||
public function testStaffOfASingleBranchEnvironmentIsBridged(): void
|
||||
@@ -182,7 +164,6 @@ class BackfillResourceTest extends ResourceTestCase
|
||||
public function testRunningTwiceCreatesNothingNew(): void
|
||||
{
|
||||
[, , $address] = $this->clinicWithAddress();
|
||||
$this->room($address, 'اتاق تکراری');
|
||||
$this->staff($address, 'اپراتور تکراری');
|
||||
|
||||
$this->runBackfill(true, $this->pairOf($address));
|
||||
@@ -190,7 +171,6 @@ class BackfillResourceTest extends ResourceTestCase
|
||||
|
||||
$secondOutput = $this->runBackfill(true, $this->pairOf($address));
|
||||
|
||||
self::assertStringContainsString('اتاق: 0', $secondOutput);
|
||||
self::assertStringContainsString('پرسنل: 0', $secondOutput);
|
||||
}
|
||||
|
||||
@@ -291,15 +271,15 @@ class BackfillResourceTest extends ResourceTestCase
|
||||
public function testASecondBridgeIsRefused(): void
|
||||
{
|
||||
[, , $address] = $this->clinicWithAddress();
|
||||
$room = $this->room($address, 'اتاق دوپل');
|
||||
$staff = $this->staff($address, 'پرسنل دوپل');
|
||||
$other = $this->staff($address, 'پرسنل دوپل دوم');
|
||||
|
||||
$type = $this->resourceType($address, 'mixed', 'ترکیبی');
|
||||
$resource = new \App\Resource\Entity\ClinicResource($address, $type, 'منبع دوپل');
|
||||
$resource->linkTo($room);
|
||||
$resource->linkTo($staff);
|
||||
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$resource->linkTo($staff);
|
||||
$resource->linkTo($other);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user