diff --git a/src/Form/Service/Condition/AccommodationMutabilityCondition.php b/src/Form/Service/Condition/AccommodationMutabilityCondition.php deleted file mode 100644 index e5bb0fc..0000000 --- a/src/Form/Service/Condition/AccommodationMutabilityCondition.php +++ /dev/null @@ -1,29 +0,0 @@ -travel->roomsMutable; - } - - public function getDependentFields(): array - { - return []; - } - - public function getDescription(): string - { - return 'Accommodation is not mutable (edit flow)'; - } -} diff --git a/src/Form/Service/EditFieldStateProvider.php b/src/Form/Service/EditFieldStateProvider.php index a2502a0..d1c4010 100644 --- a/src/Form/Service/EditFieldStateProvider.php +++ b/src/Form/Service/EditFieldStateProvider.php @@ -5,10 +5,11 @@ declare(strict_types=1); namespace App\Form\Service; use App\BusProNet\Utility\DirectionMapper; +use App\Form\Model\BookingDto; use App\Form\Service\Abstract\AbstractFieldStateProvider; -use App\Form\Service\Condition\AccommodationMutabilityCondition; use App\Form\Service\Condition\AdditionalServicesMutabilityCondition; use App\Form\Service\Condition\AgeRangeCondition; +use App\Form\Service\Condition\BookingModeCondition; use App\Form\Service\Condition\CompositeCondition; use App\Form\Service\Condition\DateOfBirthProvidedCondition; use App\Form\Service\Condition\FieldValueCondition; @@ -98,10 +99,10 @@ class EditFieldStateProvider extends AbstractFieldStateProvider 'static_text' => $personalDataHiddenCondition, ]; - // Room assignments are readonly when BPN indicates accommodation is not mutable - $accommodationMutabilityCondition = new AccommodationMutabilityCondition(); + // Room assignments are fixed in edit mode - always render as static text + // Agencies must ensure proper room assignments before booking submission $this->fieldStateConditions['assignedRoomId'] = [ - 'static_text' => $accommodationMutabilityCondition, + 'static_text' => new BookingModeCondition(BookingDto::MODE_EDIT), ]; // Show remarks room field only when room with code 'mbz' (single bed) is selected diff --git a/tests/Form/Service/Condition/AccommodationMutabilityConditionTest.php b/tests/Form/Service/Condition/AccommodationMutabilityConditionTest.php deleted file mode 100644 index 864a8a9..0000000 --- a/tests/Form/Service/Condition/AccommodationMutabilityConditionTest.php +++ /dev/null @@ -1,71 +0,0 @@ -condition = new AccommodationMutabilityCondition(); - } - - public function testReturnsFalseWhenRoomsMutable(): void - { - $travel = new Travel(); - $travel->roomsMutable = true; - - $bookingDto = new BookingDto($travel, 1); - - $result = $this->condition->evaluate($bookingDto, 0, []); - - $this->assertFalse($result, 'Should return false when rooms are mutable (field should be editable)'); - } - - public function testReturnsTrueWhenRoomsNotMutable(): void - { - $travel = new Travel(); - $travel->roomsMutable = false; - - $bookingDto = new BookingDto($travel, 1); - - $result = $this->condition->evaluate($bookingDto, 0, []); - - $this->assertTrue($result, 'Should return true when rooms are not mutable (field should be static text)'); - } - - public function testDefaultTravelHasMutableRooms(): void - { - $travel = new Travel(); - - $bookingDto = new BookingDto($travel, 1); - - $result = $this->condition->evaluate($bookingDto, 0, []); - - $this->assertFalse($result, 'Default travel should have mutable rooms'); - } - - public function testGetDependentFieldsReturnsEmptyArray(): void - { - $result = $this->condition->getDependentFields(); - - $this->assertIsArray($result); - $this->assertEmpty($result); - } - - public function testGetDescriptionReturnsString(): void - { - $result = $this->condition->getDescription(); - - $this->assertIsString($result); - $this->assertStringContainsString('not mutable', $result); - } -}