feat: revert allow updating room assignments in edit mode
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Service\Condition;
|
||||
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Service\Contract\FieldConditionInterface;
|
||||
|
||||
/**
|
||||
* Condition that checks if accommodation (room assignments) are mutable in the edit flow.
|
||||
*/
|
||||
class AccommodationMutabilityCondition implements FieldConditionInterface
|
||||
{
|
||||
public function evaluate(BookingDto $bookingDto, int $participantIndex, array $formData): bool
|
||||
{
|
||||
return false === $bookingDto->travel->roomsMutable;
|
||||
}
|
||||
|
||||
public function getDependentFields(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Accommodation is not mutable (edit flow)';
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Form\Service\Condition;
|
||||
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Service\Condition\AccommodationMutabilityCondition;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AccommodationMutabilityConditionTest extends TestCase
|
||||
{
|
||||
private AccommodationMutabilityCondition $condition;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user