From f47142c465324b62abfc9da7c375b550e3776327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Fri, 26 Jun 2026 18:02:30 +0200 Subject: [PATCH] chore: add missing branch coverage for BookingEditPreFlightChecker --- .../BookingEditPreFlightCheckerTest.php | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/tests/Service/BookingEditPreFlightCheckerTest.php b/tests/Service/BookingEditPreFlightCheckerTest.php index 0b89de2..f60b423 100644 --- a/tests/Service/BookingEditPreFlightCheckerTest.php +++ b/tests/Service/BookingEditPreFlightCheckerTest.php @@ -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 $selectionIds */