feat: improved mutability checks for personal data in edit or create mode

This commit is contained in:
Björn Fromme
2025-10-28 15:34:09 +01:00
parent 51dbf20118
commit 5021f414d1
27 changed files with 435 additions and 233 deletions
+26 -1
View File
@@ -253,11 +253,24 @@ class ParticipantEditDtoTest extends TestCase
$bookingDto = new BookingDto($travel, 1); // hotelId must be int
// Create mock booking to simulate edit mode
$mockBooking = new \App\BusProNet\Model\Booking();
$bookingDto->booking = $mockBooking;
// Create valid participants with all required fields for strict validation
$participant1 = $this->createAdultParticipant('[email protected]');
$participant1->index = 0;
$participant1->mutable = false; // Immutable - strict validation applies
$participant1->mobile = '+49 123 456789'; // Required for applicant
$participant1->address = new \App\BusProNet\Model\Address();
$participant1->address->street = 'Test Street 1';
$participant1->address->postCode = '12345';
$participant1->address->city = 'Test City';
$participant1->address->country = 'DE';
$participant2 = $this->createAdultParticipant('[email protected]');
$participant2->index = 1;
$participant2->mutable = false;
$bookingDto->participants = [$participant1, $participant2];
@@ -268,7 +281,7 @@ class ParticipantEditDtoTest extends TestCase
$violations = $this->validator->validate($wrapper, null, ['booking_edit']);
// Should have uniqueness violation in edit mode as well
// Should have uniqueness violation (edit mode with immutable applicant = strict validation)
$this->assertCount(1, $violations);
}
@@ -357,6 +370,7 @@ class ParticipantEditDtoTest extends TestCase
$participant->skiPass = $this->createMockService();
$participant->transportationOutbound = $this->createMockService();
$participant->transportationInbound = $this->createMockService();
$participant->insurance = $this->createMockInsurance();
return $participant;
}
@@ -379,6 +393,7 @@ class ParticipantEditDtoTest extends TestCase
$participant->skiPass = $this->createMockService();
$participant->transportationOutbound = $this->createMockService();
$participant->transportationInbound = $this->createMockService();
$participant->insurance = $this->createMockInsurance();
return $participant;
}
@@ -404,4 +419,14 @@ class ParticipantEditDtoTest extends TestCase
return $service;
}
private function createMockInsurance(): \App\BusProNet\Model\Insurance
{
$insurance = new \App\BusProNet\Model\Insurance();
$insurance->id = '1';
$insurance->label = 'Test Insurance';
$insurance->price = 10.0;
return $insurance;
}
}
@@ -77,7 +77,7 @@ class ParticipantValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
public function testCanceledParticipantSkipsTransportationValidation(): void
public function testCanceledParticipantSkipsValidation(): void
{
$participant = $this->createValidParticipant();
$participant->status = 'S'; // Canceled
@@ -89,22 +89,6 @@ class ParticipantValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
public function testActiveParticipantWithoutTransportationFailsValidation(): void
{
$participant = $this->createValidParticipant();
$participant->status = 'F'; // Active
$participant->transportationOutbound = null;
$participant->transportationInbound = null;
$this->validator->validate($participant, new Participant());
$this->buildViolation('Bitte angeben')
->atPath('property.path.transportationOutbound')
->buildNextViolation('Bitte angeben')
->atPath('property.path.transportationInbound')
->assertRaised();
}
public function testParticipantWithBusTransportationButNoPickupFailsValidation(): void
{
$participant = $this->createValidParticipant();