fix: allow updating room assignments in edit mode

This commit is contained in:
Björn Fromme
2026-01-30 17:29:26 +01:00
parent 0aa4bb5055
commit 6b205c7a86
11 changed files with 191 additions and 21 deletions
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Tests\Form\Model;
use App\BusProNet\Model\Travel;
use App\BusProNet\XmlLoader\AgencyLoader;
use App\Form\Model\BookingDto;
use App\Form\Model\ParticipantDto;
use App\Form\Model\ParticipantEditDto;
@@ -373,6 +374,46 @@ class ParticipantEditDtoTest extends TestCase
$this->assertCount(0, $violations5);
}
public function testInternalAgencyBookingSkipsEmailUniqueness(): void
{
$bookingDto = $this->createBookingDtoWithParticipants([
$this->createAdultParticipant('[email protected]'),
$this->createAdultParticipant('[email protected]'),
$this->createAdultParticipant('[email protected]'),
]);
// Mark as internal agency booking
$bookingDto->agencyCode = AgencyLoader::INTERNAL_AGENCY_CODE;
// Validate second participant (non-applicant adult with duplicate email)
$wrapper = new ParticipantEditDto(
participant: $bookingDto->participants[1],
bookingContext: $bookingDto,
);
$violations = $this->validator->validate($wrapper, null, ['booking_create']);
$this->assertCount(0, $violations, 'Internal agency bookings should skip email uniqueness validation');
}
public function testNonAgencyBookingStillEnforcesEmailUniqueness(): void
{
$bookingDto = $this->createBookingDtoWithParticipants([
$this->createAdultParticipant('[email protected]'),
$this->createAdultParticipant('[email protected]'),
]);
// Non-agency booking (default agencyCode is null)
$wrapper = new ParticipantEditDto(
participant: $bookingDto->participants[1],
bookingContext: $bookingDto,
);
$violations = $this->validator->validate($wrapper, null, ['booking_create']);
$this->assertCount(1, $violations, 'Non-agency bookings should still enforce email uniqueness');
}
// =========================================
// Ski Pass Validation Tests (Baby Age Exemption)
// =========================================
@@ -0,0 +1,71 @@
<?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);
}
}