767 lines
28 KiB
PHP
767 lines
28 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Service;
|
|
|
|
use App\BusProNet\Constants;
|
|
use App\BusProNet\Model\Service;
|
|
use App\BusProNet\Model\Travel;
|
|
use App\BusProNet\Service\BookingStatusRuleRegistry;
|
|
use App\BusProNet\XmlLoader\AgencyLoader;
|
|
use App\Form\Model\BookingDto;
|
|
use App\Form\Model\ParticipantDto;
|
|
use App\Service\BookingPriceCalculatorService;
|
|
use App\Service\BookingService;
|
|
use App\Service\ParticipantEligibilityService;
|
|
use App\Service\TravelDataService;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class BookingServiceBabyTest extends TestCase
|
|
{
|
|
private BookingService $bookingService;
|
|
private ParticipantEligibilityService $participantEligibilityService;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$travelDataService = $this->createMock(TravelDataService::class);
|
|
$priceCalculator = $this->createMock(BookingPriceCalculatorService::class);
|
|
$this->participantEligibilityService = $this->createMock(ParticipantEligibilityService::class);
|
|
$bookingStatusRuleRegistry = $this->createMock(BookingStatusRuleRegistry::class);
|
|
$bookingStatusRuleRegistry->method('evaluateStatus')->willReturn('F');
|
|
$agencyLoader = $this->createMock(AgencyLoader::class);
|
|
|
|
$this->bookingService = new BookingService(
|
|
$travelDataService,
|
|
$priceCalculator,
|
|
$this->participantEligibilityService,
|
|
$bookingStatusRuleRegistry,
|
|
$agencyLoader,
|
|
'F' // default booking status
|
|
);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesSkipsBabyParticipant(): void
|
|
{
|
|
$travel = $this->createTravelWithMandatoryServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
// Create a baby participant (1 year old at travel date)
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-1 year');
|
|
$participant->additionalServices = [];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertEmpty($participant->additionalServices, 'Mandatory services should not be preselected for baby participants');
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesSkipsTwoYearOldParticipant(): void
|
|
{
|
|
$travel = $this->createTravelWithMandatoryServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
// Create a participant exactly at BABY_MAX_AGE (2 years old at travel date)
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-2 years');
|
|
$participant->additionalServices = [];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertEmpty($participant->additionalServices, 'Mandatory services should not be preselected for participants at BABY_MAX_AGE');
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesIncludesThreeYearOldParticipant(): void
|
|
{
|
|
$travel = $this->createTravelWithMandatoryServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
// Create a participant just over BABY_MAX_AGE (3 years old at travel date)
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-3 years');
|
|
$participant->additionalServices = [];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
// Mock eligibility check - 3-year-old is eligible
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertNotEmpty($participant->additionalServices, 'Mandatory services should be preselected for non-baby participants');
|
|
$this->assertCount(1, $participant->additionalServices);
|
|
$this->assertSame('Mandatory Service', $participant->additionalServices[0]->label);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesIncludesAdultParticipant(): void
|
|
{
|
|
$travel = $this->createTravelWithMandatoryServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
// Create an adult participant
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$participant->additionalServices = [];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
// Mock eligibility check - adult is eligible
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertNotEmpty($participant->additionalServices, 'Mandatory services should be preselected for adult participants');
|
|
$this->assertCount(1, $participant->additionalServices);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesHandlesMixedParticipants(): void
|
|
{
|
|
$travel = $this->createTravelWithMandatoryServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
// Create a baby participant (index 0)
|
|
$babyParticipant = new ParticipantDto();
|
|
$babyParticipant->index = 0;
|
|
$babyParticipant->dateOfBirth = $travel->dateFrom->modify('-1 year');
|
|
$babyParticipant->additionalServices = [];
|
|
$bookingDto->participants[0] = $babyParticipant;
|
|
|
|
// Create an adult participant (index 1)
|
|
$adultParticipant = new ParticipantDto();
|
|
$adultParticipant->index = 1;
|
|
$adultParticipant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$adultParticipant->additionalServices = [];
|
|
$bookingDto->participants[1] = $adultParticipant;
|
|
|
|
// Mock eligibility check - adult is eligible (baby won't be checked)
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->with($bookingDto, 1) // Only called for adult
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertEmpty($babyParticipant->additionalServices, 'Baby should not have mandatory services preselected');
|
|
$this->assertNotEmpty($adultParticipant->additionalServices, 'Adult should have mandatory services preselected');
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesSkipsNewbornBaby(): void
|
|
{
|
|
$travel = $this->createTravelWithMandatoryServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
// Create a newborn (born on travel date)
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom;
|
|
$participant->additionalServices = [];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertEmpty($participant->additionalServices, 'Mandatory services should not be preselected for newborn babies');
|
|
}
|
|
|
|
public function testBabyAgeCalculatedAtTravelDate(): void
|
|
{
|
|
$travel = new Travel();
|
|
$travel->dateFrom = new \DateTimeImmutable('2025-06-01');
|
|
$travel->dateTo = new \DateTimeImmutable('2025-06-08');
|
|
$travel->additionalServices = $this->createMandatoryAdditionalServices();
|
|
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
// Create a participant who will be 2 at travel date
|
|
// Born 2023-06-02 (turns 2 on 2025-06-02), travel date 2025-06-01 = 1 year old at travel start
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = new \DateTimeImmutable('2023-06-02');
|
|
$participant->additionalServices = [];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
// At age 1, participant is a baby and should be skipped
|
|
$this->assertEmpty($participant->additionalServices, 'Age should be calculated at travel date, not current date');
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesIncludesAutoBookServiceForEligibleParticipant(): void
|
|
{
|
|
$travel = $this->createTravelWithAutoBookServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$participant->additionalServices = [];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertCount(1, $participant->additionalServices);
|
|
$this->assertSame('Auto Book Service', $participant->additionalServices[0]->label);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesRespectsAutoBookOptOut(): void
|
|
{
|
|
$travel = $this->createTravelWithAutoBookServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$participant->additionalServices = [];
|
|
$participant->autoBookOptOutServiceIds = [2];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertEmpty($participant->additionalServices);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesMandatoryOverridesAutoBookOptOut(): void
|
|
{
|
|
$travel = $this->createTravelWithMandatoryAndAutoBookService();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$participant->additionalServices = [];
|
|
$participant->autoBookOptOutServiceIds = [3];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertCount(1, $participant->additionalServices);
|
|
$this->assertSame('Mandatory And Auto Book Service', $participant->additionalServices[0]->label);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesIncludesAutoBookSkiPassForEligibleParticipant(): void
|
|
{
|
|
$travel = $this->createTravelWithAutoBookSkiPassServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertNotNull($participant->skiPass);
|
|
$this->assertSame('Auto Book Ski Pass', $participant->skiPass?->label);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesRespectsAutoBookSkiPassOptOut(): void
|
|
{
|
|
$travel = $this->createTravelWithAutoBookSkiPassServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$participant->autoBookOptOutSkiPassIds = [20];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertNull($participant->skiPass);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesMandatorySkiPassOverridesAutoBookOptOut(): void
|
|
{
|
|
$travel = $this->createTravelWithMandatoryAndAutoBookSkiPassService();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$participant->autoBookOptOutSkiPassIds = [21];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertNotNull($participant->skiPass);
|
|
$this->assertSame('Mandatory And Auto Book Ski Pass', $participant->skiPass?->label);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesIncludesAutoBookBoardForEligibleParticipant(): void
|
|
{
|
|
$travel = $this->createTravelWithAutoBookBoardServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertCount(1, $participant->board);
|
|
$this->assertSame('Auto Book Board', $participant->board[0]->label);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesRespectsAutoBookBoardOptOut(): void
|
|
{
|
|
$travel = $this->createTravelWithAutoBookBoardServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$participant->autoBookOptOutBoardIds = [40];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertSame([], $participant->board);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesMandatoryBoardOverridesAutoBookOptOut(): void
|
|
{
|
|
$travel = $this->createTravelWithMandatoryAndAutoBookBoardService();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$participant->autoBookOptOutBoardIds = [41];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertCount(1, $participant->board);
|
|
$this->assertSame('Mandatory And Auto Book Board', $participant->board[0]->label);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesIncludesAutoBookRentalForMatchingSkiPass(): void
|
|
{
|
|
$travel = $this->createTravelWithAutoBookRentalServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$participant->skiPass = $travel->additionalServices[20];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertCount(1, $participant->rentals);
|
|
$this->assertSame('Auto Book Rental', $participant->rentals[0]->label);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesRespectsAutoBookRentalOptOut(): void
|
|
{
|
|
$travel = $this->createTravelWithAutoBookRentalServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$participant->skiPass = $travel->additionalServices[20];
|
|
$participant->autoBookOptOutRentalIds = [50];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertSame([], $participant->rentals);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesMandatoryRentalOverridesAutoBookOptOut(): void
|
|
{
|
|
$travel = $this->createTravelWithMandatoryAndAutoBookRentalServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$participant->skiPass = $travel->additionalServices[22];
|
|
$participant->autoBookOptOutRentalIds = [51];
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertCount(1, $participant->rentals);
|
|
$this->assertSame('Mandatory And Auto Book Rental', $participant->rentals[0]->label);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesSkipsAutoBookRentalWithoutSkiPass(): void
|
|
{
|
|
$travel = $this->createTravelWithAutoBookRentalServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertSame([], $participant->rentals);
|
|
}
|
|
|
|
public function testPreselectMandatoryServicesSkipsAutoBookRentalForNonMatchingSkiPassDuration(): void
|
|
{
|
|
$travel = $this->createTravelWithAutoBookRentalServices();
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$participant = new ParticipantDto();
|
|
$participant->index = 0;
|
|
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
|
$participant->skiPass = new Service();
|
|
$participant->skiPass->id = 99;
|
|
$participant->skiPass->subType = Constants::TOKEN_SKI_PASS;
|
|
$participant->skiPass->dateFrom = new \DateTimeImmutable('+31 days');
|
|
$participant->skiPass->dateTo = new \DateTimeImmutable('+35 days');
|
|
$bookingDto->participants[0] = $participant;
|
|
|
|
$this->participantEligibilityService
|
|
->method('isParticipantEligible')
|
|
->willReturn(true);
|
|
|
|
$this->bookingService->preselectMandatoryServices($bookingDto);
|
|
|
|
$this->assertSame([], $participant->rentals);
|
|
}
|
|
|
|
private function createTravelWithMandatoryServices(): Travel
|
|
{
|
|
$travel = new Travel();
|
|
$travel->dateFrom = new \DateTimeImmutable('+30 days');
|
|
$travel->dateTo = new \DateTimeImmutable('+37 days');
|
|
$travel->additionalServices = $this->createMandatoryAdditionalServices();
|
|
|
|
return $travel;
|
|
}
|
|
|
|
private function createTravelWithAutoBookServices(): Travel
|
|
{
|
|
$travel = new Travel();
|
|
$travel->dateFrom = new \DateTimeImmutable('+30 days');
|
|
$travel->dateTo = new \DateTimeImmutable('+37 days');
|
|
$travel->additionalServices = $this->createAutoBookAdditionalServices();
|
|
|
|
return $travel;
|
|
}
|
|
|
|
private function createTravelWithMandatoryAndAutoBookService(): Travel
|
|
{
|
|
$travel = new Travel();
|
|
$travel->dateFrom = new \DateTimeImmutable('+30 days');
|
|
$travel->dateTo = new \DateTimeImmutable('+37 days');
|
|
$travel->additionalServices = $this->createMandatoryAndAutoBookAdditionalServices();
|
|
|
|
return $travel;
|
|
}
|
|
|
|
private function createTravelWithAutoBookSkiPassServices(): Travel
|
|
{
|
|
$travel = new Travel();
|
|
$travel->dateFrom = new \DateTimeImmutable('+30 days');
|
|
$travel->dateTo = new \DateTimeImmutable('+37 days');
|
|
$travel->additionalServices = $this->createAutoBookSkiPassServices();
|
|
|
|
return $travel;
|
|
}
|
|
|
|
private function createTravelWithMandatoryAndAutoBookSkiPassService(): Travel
|
|
{
|
|
$travel = new Travel();
|
|
$travel->dateFrom = new \DateTimeImmutable('+30 days');
|
|
$travel->dateTo = new \DateTimeImmutable('+37 days');
|
|
$travel->additionalServices = $this->createMandatoryAndAutoBookSkiPassServices();
|
|
|
|
return $travel;
|
|
}
|
|
|
|
private function createTravelWithAutoBookBoardServices(): Travel
|
|
{
|
|
$travel = new Travel();
|
|
$travel->dateFrom = new \DateTimeImmutable('+30 days');
|
|
$travel->dateTo = new \DateTimeImmutable('+37 days');
|
|
$travel->additionalServices = $this->createAutoBookBoardServices();
|
|
|
|
return $travel;
|
|
}
|
|
|
|
private function createTravelWithMandatoryAndAutoBookBoardService(): Travel
|
|
{
|
|
$travel = new Travel();
|
|
$travel->dateFrom = new \DateTimeImmutable('+30 days');
|
|
$travel->dateTo = new \DateTimeImmutable('+37 days');
|
|
$travel->additionalServices = $this->createMandatoryAndAutoBookBoardServices();
|
|
|
|
return $travel;
|
|
}
|
|
|
|
private function createTravelWithAutoBookRentalServices(): Travel
|
|
{
|
|
$travel = new Travel();
|
|
$travel->dateFrom = new \DateTimeImmutable('2030-01-01');
|
|
$travel->dateTo = new \DateTimeImmutable('2030-01-08');
|
|
$travel->additionalServices = $this->createAutoBookRentalServices();
|
|
|
|
return $travel;
|
|
}
|
|
|
|
private function createTravelWithMandatoryAndAutoBookRentalServices(): Travel
|
|
{
|
|
$travel = new Travel();
|
|
$travel->dateFrom = new \DateTimeImmutable('2030-01-01');
|
|
$travel->dateTo = new \DateTimeImmutable('2030-01-08');
|
|
$travel->additionalServices = $this->createMandatoryAndAutoBookRentalServices();
|
|
|
|
return $travel;
|
|
}
|
|
|
|
/**
|
|
* @return array<int, Service>
|
|
*/
|
|
private function createMandatoryAdditionalServices(): array
|
|
{
|
|
$mandatoryService = new Service();
|
|
$mandatoryService->id = 1;
|
|
$mandatoryService->label = 'Mandatory Service';
|
|
$mandatoryService->subType = Constants::TOKEN_ADDITIONAL;
|
|
$mandatoryService->mandatory = true;
|
|
$mandatoryService->available = 10;
|
|
$mandatoryService->price = 10.0;
|
|
|
|
return [1 => $mandatoryService];
|
|
}
|
|
|
|
/**
|
|
* @return array<int, Service>
|
|
*/
|
|
private function createAutoBookAdditionalServices(): array
|
|
{
|
|
$autoBookService = new Service();
|
|
$autoBookService->id = 2;
|
|
$autoBookService->label = 'Auto Book Service';
|
|
$autoBookService->subType = Constants::TOKEN_ADDITIONAL;
|
|
$autoBookService->mandatory = false;
|
|
$autoBookService->autoBook = true;
|
|
$autoBookService->available = 10;
|
|
$autoBookService->price = 10.0;
|
|
|
|
return [2 => $autoBookService];
|
|
}
|
|
|
|
/**
|
|
* @return array<int, Service>
|
|
*/
|
|
private function createMandatoryAndAutoBookAdditionalServices(): array
|
|
{
|
|
$service = new Service();
|
|
$service->id = 3;
|
|
$service->label = 'Mandatory And Auto Book Service';
|
|
$service->subType = Constants::TOKEN_ADDITIONAL;
|
|
$service->mandatory = true;
|
|
$service->autoBook = true;
|
|
$service->available = 10;
|
|
$service->price = 10.0;
|
|
|
|
return [3 => $service];
|
|
}
|
|
|
|
/**
|
|
* @return array<int, Service>
|
|
*/
|
|
private function createAutoBookSkiPassServices(): array
|
|
{
|
|
$service = new Service();
|
|
$service->id = 20;
|
|
$service->label = 'Auto Book Ski Pass';
|
|
$service->subType = Constants::TOKEN_SKI_PASS;
|
|
$service->mandatory = false;
|
|
$service->autoBook = true;
|
|
$service->available = 10;
|
|
$service->price = 59.0;
|
|
$service->dateFrom = new \DateTimeImmutable('+30 days');
|
|
$service->dateTo = new \DateTimeImmutable('+36 days');
|
|
|
|
return [20 => $service];
|
|
}
|
|
|
|
/**
|
|
* @return array<int, Service>
|
|
*/
|
|
private function createMandatoryAndAutoBookSkiPassServices(): array
|
|
{
|
|
$service = new Service();
|
|
$service->id = 21;
|
|
$service->label = 'Mandatory And Auto Book Ski Pass';
|
|
$service->subType = Constants::TOKEN_SKI_PASS;
|
|
$service->mandatory = true;
|
|
$service->autoBook = true;
|
|
$service->available = 10;
|
|
$service->price = 59.0;
|
|
$service->dateFrom = new \DateTimeImmutable('+30 days');
|
|
$service->dateTo = new \DateTimeImmutable('+36 days');
|
|
|
|
return [21 => $service];
|
|
}
|
|
|
|
/**
|
|
* @return array<int, Service>
|
|
*/
|
|
private function createAutoBookBoardServices(): array
|
|
{
|
|
$service = new Service();
|
|
$service->id = 40;
|
|
$service->label = 'Auto Book Board';
|
|
$service->subType = Constants::TOKEN_BOARD;
|
|
$service->mandatory = false;
|
|
$service->autoBook = true;
|
|
$service->available = 10;
|
|
$service->price = 12.0;
|
|
|
|
return [40 => $service];
|
|
}
|
|
|
|
/**
|
|
* @return array<int, Service>
|
|
*/
|
|
private function createMandatoryAndAutoBookBoardServices(): array
|
|
{
|
|
$service = new Service();
|
|
$service->id = 41;
|
|
$service->label = 'Mandatory And Auto Book Board';
|
|
$service->subType = Constants::TOKEN_BOARD;
|
|
$service->mandatory = true;
|
|
$service->autoBook = true;
|
|
$service->available = 10;
|
|
$service->price = 12.0;
|
|
|
|
return [41 => $service];
|
|
}
|
|
|
|
/**
|
|
* @return array<int, Service>
|
|
*/
|
|
private function createAutoBookRentalServices(): array
|
|
{
|
|
$serviceDateFrom = new \DateTimeImmutable('2030-01-01');
|
|
$serviceDateTo = new \DateTimeImmutable('2030-01-07');
|
|
|
|
$skiPass = new Service();
|
|
$skiPass->id = 20;
|
|
$skiPass->label = 'Matching Ski Pass';
|
|
$skiPass->subType = Constants::TOKEN_SKI_PASS;
|
|
$skiPass->mandatory = false;
|
|
$skiPass->autoBook = false;
|
|
$skiPass->available = 10;
|
|
$skiPass->price = 59.0;
|
|
$skiPass->dateFrom = $serviceDateFrom;
|
|
$skiPass->dateTo = $serviceDateTo;
|
|
|
|
$rental = new Service();
|
|
$rental->id = 50;
|
|
$rental->label = 'Auto Book Rental';
|
|
$rental->subType = 'VER';
|
|
$rental->mandatory = false;
|
|
$rental->autoBook = true;
|
|
$rental->available = 10;
|
|
$rental->price = 39.0;
|
|
$rental->dateFrom = $serviceDateFrom;
|
|
$rental->dateTo = $serviceDateTo;
|
|
|
|
return [20 => $skiPass, 50 => $rental];
|
|
}
|
|
|
|
/**
|
|
* @return array<int, Service>
|
|
*/
|
|
private function createMandatoryAndAutoBookRentalServices(): array
|
|
{
|
|
$serviceDateFrom = new \DateTimeImmutable('2030-01-01');
|
|
$serviceDateTo = new \DateTimeImmutable('2030-01-07');
|
|
|
|
$skiPass = new Service();
|
|
$skiPass->id = 22;
|
|
$skiPass->label = 'Matching Ski Pass Mandatory Rental';
|
|
$skiPass->subType = Constants::TOKEN_SKI_PASS;
|
|
$skiPass->mandatory = false;
|
|
$skiPass->autoBook = false;
|
|
$skiPass->available = 10;
|
|
$skiPass->price = 59.0;
|
|
$skiPass->dateFrom = $serviceDateFrom;
|
|
$skiPass->dateTo = $serviceDateTo;
|
|
|
|
$rental = new Service();
|
|
$rental->id = 51;
|
|
$rental->label = 'Mandatory And Auto Book Rental';
|
|
$rental->subType = 'VER';
|
|
$rental->mandatory = true;
|
|
$rental->autoBook = true;
|
|
$rental->available = 10;
|
|
$rental->price = 39.0;
|
|
$rental->dateFrom = $serviceDateFrom;
|
|
$rental->dateTo = $serviceDateTo;
|
|
|
|
return [22 => $skiPass, 51 => $rental];
|
|
}
|
|
}
|