feat: fill default names for canceled participants in agency bookings

This commit is contained in:
Björn Fromme
2026-03-16 12:03:00 +01:00
parent eda0919f52
commit 06f53ba6eb
3 changed files with 148 additions and 3 deletions
@@ -534,4 +534,123 @@ class BookingDataProcessorTest extends TestCase
return $pickup;
}
public function testCanceledParticipantEmptyNamesFilledForAgencyBooking(): void
{
$formData = $this->createFormDataWithCanceledParticipantEmptyNames();
$this->processor->createUpdateRequestPayload($formData);
// Canceled participant (index 1) should have default names filled
$canceledParticipant = $formData->booking->participants[1];
$this->assertEquals('Teilnehmer:in 2', $canceledParticipant->firstName);
$this->assertEquals('Teilnehmer:in 2', $canceledParticipant->name);
// Active participant (index 0) should retain original names from form
$activeParticipant = $formData->booking->participants[0];
$this->assertEquals('Participant0', $activeParticipant->firstName);
$this->assertEquals('LastName', $activeParticipant->name);
}
public function testCanceledParticipantNamesNotFilledForNonAgencyBooking(): void
{
$formData = $this->createFormDataWithCanceledParticipantEmptyNamesNonAgency();
$this->processor->createUpdateRequestPayload($formData);
// Canceled participant should retain empty names (non-agency booking)
$canceledParticipant = $formData->booking->participants[1];
$this->assertEquals('', $canceledParticipant->firstName);
$this->assertEquals('', $canceledParticipant->name);
}
private function createFormDataWithCanceledParticipantEmptyNames(): BookingDto
{
$bookingDto = new BookingDto($this->createMockTravel(), 1);
$bookingDto->booking = $this->createMockBookingWithCanceledParticipantEmptyNames();
$bookingDto->agencyCode = '0004'; // Internal agency code to trigger isInternalAgencyBooking()
$bookingDto->participants = [
$this->createMockParticipantDto(0, 'F'),
$this->createMockParticipantDtoWithEmptyNames(1, 'S'),
];
return $bookingDto;
}
private function createFormDataWithCanceledParticipantEmptyNamesNonAgency(): BookingDto
{
$bookingDto = new BookingDto($this->createMockTravel(), 1);
$bookingDto->booking = $this->createMockBookingWithCanceledParticipantEmptyNames();
$bookingDto->agencyCode = null; // No agency - not an internal agency booking
$bookingDto->participants = [
$this->createMockParticipantDto(0, 'F'),
$this->createMockParticipantDtoWithEmptyNames(1, 'S'),
];
return $bookingDto;
}
private function createMockBookingWithCanceledParticipantEmptyNames(): Booking
{
$booking = new Booking();
$booking->id = 123;
$booking->status = 'ACTIVE';
$booking->agencyId = 999;
$booking->dateId = 1;
$booking->hotelId = 1;
$booking->paymentId = '1';
$booking->paymentLabel = 'Credit Card';
$booking->paymentType = 'CC';
$booking->additionalServices = [];
$booking->transportationServices = [];
$booking->pickupsOutbound = [];
$booking->pickupsInbound = [];
$canceledParticipant = new PersonalData();
$canceledParticipant->firstName = '';
$canceledParticipant->name = '';
$canceledParticipant->dateOfBirth = new \DateTimeImmutable('1990-01-01');
$canceledParticipant->gender = 'M';
$canceledParticipant->nationality = 'DE';
$canceledParticipant->address = new Address();
$canceledParticipant->communication = new Communication();
$booking->participants = [
$this->createMockPersonalData('Participant0'),
$canceledParticipant,
];
$booking->participantsStatus = ['F', 'S']; // Second participant is canceled
$booking->applicant = $this->createMockPersonalData('Applicant');
$booking->bankAccount = null;
$booking->rooms = [];
return $booking;
}
private function createMockParticipantDtoWithEmptyNames(int $index, string $status): ParticipantDto
{
$participant = new ParticipantDto();
$participant->index = $index;
$participant->status = $status;
$participant->firstName = '';
$participant->lastName = '';
$participant->dateOfBirth = new \DateTimeImmutable('1990-01-01');
$participant->gender = 'M';
$participant->nationality = 'DE';
$participant->height = '175';
$participant->weight = '70';
$participant->shoeSize = '40';
$participant->email = null;
$participant->mobile = null;
$participant->courses = [];
$participant->additionalServices = [];
$participant->skiPass = null;
$participant->board = [];
$participant->rentals = [];
$participant->transportationOutbound = $this->createMockService(1);
$participant->transportationInbound = $this->createMockService(2);
$participant->pickup = null;
return $participant;
}
}