rule = new ChaperonServiceStatusRule(); } public function testReturnsTrueWhenBegleitpersonInAdditionalServices(): void { $bookingDto = $this->createBookingDtoWithParticipant(); $service = new Service(); $service->label = 'Skibegleitperson Kurs'; $bookingDto->participants[0]->additionalServices = [$service]; $this->assertTrue($this->rule->evaluate($bookingDto)); } public function testReturnsTrueWhenBegleitpersonInCourses(): void { $bookingDto = $this->createBookingDtoWithParticipant(); $service = new Service(); $service->label = 'Begleitperson Anfaengerkurs'; $bookingDto->participants[0]->courses = [$service]; $this->assertTrue($this->rule->evaluate($bookingDto)); } public function testReturnsTrueWhenBegleitpersonInBoard(): void { $bookingDto = $this->createBookingDtoWithParticipant(); $service = new Service(); $service->label = 'Halbpension Begleitperson'; $bookingDto->participants[0]->board = [$service]; $this->assertTrue($this->rule->evaluate($bookingDto)); } public function testReturnsTrueWhenBegleitpersonInRentals(): void { $bookingDto = $this->createBookingDtoWithParticipant(); $service = new Service(); $service->label = 'Skiset Begleitperson'; $bookingDto->participants[0]->rentals = [$service]; $this->assertTrue($this->rule->evaluate($bookingDto)); } public function testReturnsTrueWhenBegleitpersonInSkiPass(): void { $bookingDto = $this->createBookingDtoWithParticipant(); $service = new Service(); $service->label = 'Skipass Begleitperson 6 Tage'; $bookingDto->participants[0]->skiPass = $service; $this->assertTrue($this->rule->evaluate($bookingDto)); } public function testReturnsTrueWhenBegleitpersonInVeg(): void { $bookingDto = $this->createBookingDtoWithParticipant(); $service = new Service(); $service->label = 'Vegetarisch Begleitperson'; $bookingDto->participants[0]->veg = $service; $this->assertTrue($this->rule->evaluate($bookingDto)); } public function testReturnsTrueWhenSecondParticipantMatches(): void { $bookingDto = $this->createBookingDtoWithParticipantCount(2); $service = new Service(); $service->label = 'Begleitperson Service'; $bookingDto->participants[1]->additionalServices = [$service]; $this->assertTrue($this->rule->evaluate($bookingDto)); } public function testReturnsFalseWhenNoBegleitpersonService(): void { $bookingDto = $this->createBookingDtoWithParticipant(); $service = new Service(); $service->label = 'Skipass 6 Tage Erwachsene'; $bookingDto->participants[0]->skiPass = $service; $this->assertFalse($this->rule->evaluate($bookingDto)); } public function testReturnsFalseWithEmptyParticipants(): void { $bookingDto = new BookingDto($this->createTravel(), 1); $this->assertFalse($this->rule->evaluate($bookingDto)); } public function testCaseInsensitiveMatch(): void { $bookingDto = $this->createBookingDtoWithParticipant(); $service = new Service(); $service->label = 'BEGLEITPERSON Kurs'; $bookingDto->participants[0]->additionalServices = [$service]; $this->assertTrue($this->rule->evaluate($bookingDto)); } public function testReturnsStatusO(): void { $this->assertSame('O', $this->rule->getStatus()); } public function testGetPriorityReturns100(): void { $this->assertSame(100, $this->rule->getPriority()); } public function testGetDescriptionReturnsNonEmptyString(): void { $description = $this->rule->getDescription(); $this->assertIsString($description); $this->assertNotEmpty($description); } private function createBookingDtoWithParticipant(): BookingDto { return $this->createBookingDtoWithParticipantCount(1); } private function createBookingDtoWithParticipantCount(int $count): BookingDto { $bookingDto = new BookingDto($this->createTravel(), 1); for ($i = 0; $i < $count; ++$i) { $participant = new ParticipantDto(); $participant->index = $i; $bookingDto->participants[$i] = $participant; } return $bookingDto; } private function createTravel(): Travel { $travel = new Travel(); $travel->id = 1; $travel->hotelId = 1; $travel->dateFrom = new \DateTimeImmutable('2030-01-01'); $travel->dateTo = new \DateTimeImmutable('2030-01-08'); return $travel; } }