chore: add missing branch coverage for BookingEditPreFlightChecker

This commit is contained in:
Björn Fromme
2026-07-10 14:33:09 +02:00
parent 3105f2e7a0
commit f47142c465
@@ -317,6 +317,107 @@ class BookingEditPreFlightCheckerTest extends TestCase
return $bookingDto;
}
public function testScanAttentionReturnsEmptyArrayForCreateMode(): void
{
$travel = new Travel();
$travel->dateFrom = CarbonImmutable::now()->addMonth()->toDateTimeImmutable();
$bookingDto = new BookingDto($travel, 1);
// No $bookingDto->booking set → getMode() returns MODE_CREATE
$participant = $this->createCompleteParticipant(0);
$participant->firstName = null;
$participant->lastName = null;
$bookingDto->participants = [$participant];
$checker = new BookingEditPreFlightChecker($this->createValidator());
$this->assertSame([], $checker->findMissingValueLabelsByParticipantIndex($bookingDto));
}
public function testScanAttentionSkipsCanceledParticipants(): void
{
$bookingDto = $this->createBookingDto(true);
$canceledParticipant = $this->createCompleteParticipant(1);
$canceledParticipant->status = 'S';
$canceledParticipant->firstName = null;
$canceledParticipant->lastName = null;
$canceledParticipant->email = null;
$bookingDto->participants = [
$this->createCompleteParticipant(0),
$canceledParticipant,
];
$checker = new BookingEditPreFlightChecker($this->createValidator());
$this->assertSame([], $checker->findMissingValueLabelsByParticipantIndex($bookingDto));
}
public function testScanAttentionFlagsEmailUniquenessViolationForDuplicateAdultEmail(): void
{
$bookingDto = $this->createBookingDto(false);
// All three participants share the same email address (from createCompleteParticipant).
// Index 0 (applicant) is exempt; indices 1 and 2 each see a duplicate and are flagged.
$bookingDto->participants = [
$this->createCompleteParticipant(0),
$this->createCompleteParticipant(1),
$this->createCompleteParticipant(2),
];
$checker = new BookingEditPreFlightChecker($this->createValidator());
$this->assertSame(
[
1 => ['E-Mail'],
2 => ['E-Mail'],
],
$checker->findMissingValueLabelsByParticipantIndex($bookingDto)
);
}
public function testScanAttentionCoversRemainingPropertyLabels(): void
{
$bookingDto = $this->createBookingDto(true);
$participant = $this->createCompleteParticipant(0);
$participant->gender = null;
$participant->nationality = null;
$participant->dateOfBirth = null;
$participant->assignedRoomId = null;
$participant->transportationOutbound = null;
$participant->transportationInbound = null;
$bookingDto->participants = [$participant];
$checker = new BookingEditPreFlightChecker($this->createValidator());
$this->assertSame(
[0 => ['Anrede', 'Nationalität', 'Geburtsdatum', 'Zimmer', 'Anreise', 'Abreise']],
$checker->findMissingValueLabelsByParticipantIndex($bookingDto)
);
}
public function testScanAttentionFlagsAddressFieldLabelsForApplicantInNonInternalAgencyBooking(): void
{
$bookingDto = $this->createBookingDto(false);
$participant = $this->createCompleteParticipant(0);
$participant->address = new Address();
$bookingDto->participants = [$participant];
$checker = new BookingEditPreFlightChecker($this->createValidator());
$this->assertSame(
[0 => ['Straße', 'PLZ', 'Ort', 'Land']],
$checker->findMissingValueLabelsByParticipantIndex($bookingDto)
);
}
/**
* @param list<int> $selectionIds
*/