feat: auto-booking services
addresses #869cfcptv
This commit is contained in:
1 parent
6d9265de0f
commit
c510cbf590
19 files changed
+1829
-72
No files matched your search
@@ -32,7 +32,7 @@ class TravelParserTest extends TestCase
|
||||
<preis>0,00</preis>
|
||||
<status>Frei</status>
|
||||
</leistung>
|
||||
<leistung id="2" idbuspro="183659" unterart="SON" termin="01.01.2030" bis="06.01.2030" automatisch_buchen="False" pflicht="False">
|
||||
<leistung id="2" idbuspro="183659" unterart="SON" termin="01.01.2030" bis="06.01.2030" automatisch_buchen="True" pflicht="False">
|
||||
<text>Bettwäsche-Set inkl. Handtuch</text>
|
||||
<hinweis>Das Bettwäsche-Set umfasst Spannbettlaken, Kissen- und Deckenbezug. Beim Handtuch handelt es sich um ein Duschtuch (ca. 70x140cm).</hinweis>
|
||||
<preis>13,90</preis>
|
||||
@@ -92,6 +92,7 @@ class TravelParserTest extends TestCase
|
||||
'Das Bettwäsche-Set umfasst Spannbettlaken, Kissen- und Deckenbezug. Beim Handtuch handelt es sich um ein Duschtuch (ca. 70x140cm).',
|
||||
$bettwascheService->description
|
||||
);
|
||||
$this->assertTrue($bettwascheService->autoBook);
|
||||
|
||||
// Service without description (ID 183656 - Skipass, has hinweis_stamm but no hinweis)
|
||||
$this->assertArrayHasKey(183656, $additionalServices);
|
||||
@@ -112,6 +113,7 @@ class TravelParserTest extends TestCase
|
||||
$busService = $transportationServices[183649];
|
||||
$this->assertSame('Bus-Hinfahrt', $busService->label);
|
||||
$this->assertSame('Bus fährt nur bei ausreichender Teilnehmerzahl', $busService->description);
|
||||
$this->assertFalse($busService->autoBook);
|
||||
}
|
||||
|
||||
public function testParseServiceWithoutDescriptions(): void
|
||||
@@ -149,6 +151,39 @@ class TravelParserTest extends TestCase
|
||||
$this->assertNull($service->description); // No hinweis node should result in null description
|
||||
}
|
||||
|
||||
public function testParseServiceWithLowerCaseAutoBookFlag(): void
|
||||
{
|
||||
$xmlContent = '<?xml version="1.0" encoding="utf-8"?>
|
||||
<reisen>
|
||||
<reise id="1" idbuspro="2187" code="SSTMR">
|
||||
<termin id="1" idbuspro="11946" termin="01.01.2030" bis="06.01.2030" reiseart="F">
|
||||
<text>Test Travel</text>
|
||||
<abpreis>659,00</abpreis>
|
||||
<lei_sonstiges>
|
||||
<leistung id="1" idbuspro="183660" unterart="VPF" automatisch_buchen="true" pflicht="False">
|
||||
<text>Service with auto-book</text>
|
||||
<preis>8,90</preis>
|
||||
<status>Frei</status>
|
||||
</leistung>
|
||||
</lei_sonstiges>
|
||||
<hotel id="1" idbuspro="157047">
|
||||
<zimmer>
|
||||
<preis zimmercode="4erDW" idbuspro_zimmer="95" zimmertext="4er Zimmer" MinPax="4" MaxPax="4" naechte="5" preis="689,00" status="Frei" verfuegbar="8" />
|
||||
</zimmer>
|
||||
</hotel>
|
||||
</termin>
|
||||
</reise>
|
||||
</reisen>';
|
||||
|
||||
$crawler = new Crawler($xmlContent);
|
||||
$travelNode = $crawler->filterXPath('//reise/termin')->first();
|
||||
$travel = $this->parser->parse($travelNode);
|
||||
|
||||
$additionalServices = $travel->additionalServices;
|
||||
$this->assertArrayHasKey(183660, $additionalServices);
|
||||
$this->assertTrue($additionalServices[183660]->autoBook);
|
||||
}
|
||||
|
||||
public function testParseServiceWithEmptyDescription(): void
|
||||
{
|
||||
$xmlContent = '<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Controller\Booking;
|
||||
|
||||
use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Controller\Booking\Traits\ParticipantCardFlowTrait;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\BookingSummaryDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Service\BookingService;
|
||||
use App\Service\BookingSummaryDataService;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class ParticipantCardFlowTraitTest extends TestCase
|
||||
{
|
||||
public function testHandleParticipantRefreshReappliesDefaultPreselectionInEditMode(): void
|
||||
{
|
||||
$bookingService = $this->createMock(BookingService::class);
|
||||
$summaryDataService = $this->createMock(BookingSummaryDataService::class);
|
||||
|
||||
$formOne = $this->createMock(FormInterface::class);
|
||||
$formOne->expects($this->once())
|
||||
->method('handleRequest');
|
||||
$formOne->method('isSubmitted')
|
||||
->willReturn(true);
|
||||
|
||||
$formTwo = $this->createMock(FormInterface::class);
|
||||
$formTwo->expects($this->once())
|
||||
->method('createView')
|
||||
->willReturn(new FormView());
|
||||
|
||||
$bookingDto = $this->createEditModeBookingDto();
|
||||
$request = new Request();
|
||||
|
||||
$bookingService->expects($this->once())
|
||||
->method('preselectDefaultServices')
|
||||
->with($bookingDto);
|
||||
|
||||
$bookingService->expects($this->once())
|
||||
->method('saveBookingDto')
|
||||
->with($request, $bookingDto, BookingDto::MODE_EDIT);
|
||||
|
||||
$summaryDataService->expects($this->once())
|
||||
->method('getSummaryData')
|
||||
->with($bookingDto)
|
||||
->willReturn(new BookingSummaryDto([], 1, 0.0, 0.0, [], [], [], null));
|
||||
|
||||
$controller = new class($bookingService, $summaryDataService, [$formOne, $formTwo]) {
|
||||
use ParticipantCardFlowTrait;
|
||||
|
||||
public BookingService $bookingService;
|
||||
public BookingSummaryDataService $summaryDataService;
|
||||
public object $participantCardService;
|
||||
|
||||
/** @var FormInterface[] */
|
||||
private array $forms;
|
||||
|
||||
public function __construct(BookingService $bookingService, BookingSummaryDataService $summaryDataService, array $forms)
|
||||
{
|
||||
$this->bookingService = $bookingService;
|
||||
$this->summaryDataService = $summaryDataService;
|
||||
$this->forms = $forms;
|
||||
$this->participantCardService = new class() {
|
||||
public function getAllCardsData(BookingDto $bookingDto): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public function callHandleParticipantRefresh(
|
||||
Request $request,
|
||||
BookingDto $bookingDto,
|
||||
int $index,
|
||||
string $refreshRouteName,
|
||||
): Response {
|
||||
$method = new \ReflectionMethod($this, 'handleParticipantRefresh');
|
||||
$method->setAccessible(true);
|
||||
|
||||
return $method->invoke($this, $request, $bookingDto, $index, $refreshRouteName);
|
||||
}
|
||||
|
||||
private function htmxOobResponse(string $template, array $blocks, array $parameters): Response
|
||||
{
|
||||
return new Response('ok');
|
||||
}
|
||||
|
||||
protected function getParameter(string $name): mixed
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function createForm(string $type, $data = null, array $options = []): FormInterface
|
||||
{
|
||||
return array_shift($this->forms);
|
||||
}
|
||||
|
||||
private function render(string $view, array $parameters = [], ?Response $response = null): Response
|
||||
{
|
||||
return new Response('rendered');
|
||||
}
|
||||
|
||||
protected function addFlash(string $type, mixed $message): void
|
||||
{
|
||||
}
|
||||
|
||||
protected function redirectToRoute(string $route, array $parameters = [], int $status = 302): RedirectResponse
|
||||
{
|
||||
return new RedirectResponse('/');
|
||||
}
|
||||
};
|
||||
|
||||
$response = $controller->callHandleParticipantRefresh(
|
||||
$request,
|
||||
$bookingDto,
|
||||
0,
|
||||
'app_booking_edit_step_2_participant_refresh'
|
||||
);
|
||||
|
||||
$this->assertSame('ok', $response->getContent());
|
||||
}
|
||||
|
||||
private function createEditModeBookingDto(): BookingDto
|
||||
{
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('2030-01-01');
|
||||
$travel->dateTo = new \DateTimeImmutable('2030-01-06');
|
||||
|
||||
$bookingDto = new BookingDto($travel, 157047);
|
||||
$bookingDto->booking = new Booking(); // Marks DTO as edit mode
|
||||
|
||||
$participant = new ParticipantDto();
|
||||
$participant->index = 0;
|
||||
$participant->dateOfBirth = new \DateTimeImmutable('1990-01-01');
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
return $bookingDto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Form\Service;
|
||||
|
||||
use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\ParticipantAdditionalServicesFieldHandler;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParticipantAdditionalServicesFieldHandlerTest extends TestCase
|
||||
{
|
||||
public function testDeselectAutoBookServiceAddsOptOutId(): void
|
||||
{
|
||||
$autoBookService = new Service();
|
||||
$autoBookService->id = 10;
|
||||
$autoBookService->subType = Constants::TOKEN_ADDITIONAL;
|
||||
$autoBookService->label = 'Auto Book';
|
||||
$autoBookService->autoBook = true;
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('+30 days');
|
||||
$travel->dateTo = new \DateTimeImmutable('+37 days');
|
||||
$travel->additionalServices = [10 => $autoBookService];
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$participant = new ParticipantDto();
|
||||
$participant->index = 0;
|
||||
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
||||
$participant->additionalServices = [$autoBookService];
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
$handler = new ParticipantAdditionalServicesFieldHandler();
|
||||
$handler->processField([], $bookingDto, 0);
|
||||
|
||||
$this->assertSame([10], $participant->autoBookOptOutServiceIds);
|
||||
$this->assertSame([], $participant->additionalServices);
|
||||
}
|
||||
|
||||
public function testDeselectMandatoryAutoBookServiceDoesNotAddOptOutId(): void
|
||||
{
|
||||
$service = new Service();
|
||||
$service->id = 11;
|
||||
$service->subType = Constants::TOKEN_ADDITIONAL;
|
||||
$service->label = 'Mandatory Auto Book';
|
||||
$service->mandatory = true;
|
||||
$service->autoBook = true;
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('+30 days');
|
||||
$travel->dateTo = new \DateTimeImmutable('+37 days');
|
||||
$travel->additionalServices = [11 => $service];
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$participant = new ParticipantDto();
|
||||
$participant->index = 0;
|
||||
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
||||
$participant->additionalServices = [$service];
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
$handler = new ParticipantAdditionalServicesFieldHandler();
|
||||
$handler->processField([], $bookingDto, 0);
|
||||
|
||||
$this->assertSame([], $participant->autoBookOptOutServiceIds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Form\Service;
|
||||
|
||||
use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\ParticipantBoardFieldHandler;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParticipantBoardFieldHandlerTest extends TestCase
|
||||
{
|
||||
public function testDeselectAutoBookBoardAddsOptOutId(): void
|
||||
{
|
||||
$autoBookBoard = new Service();
|
||||
$autoBookBoard->id = 60;
|
||||
$autoBookBoard->subType = Constants::TOKEN_BOARD;
|
||||
$autoBookBoard->label = 'Auto Book Board';
|
||||
$autoBookBoard->autoBook = true;
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('+30 days');
|
||||
$travel->dateTo = new \DateTimeImmutable('+37 days');
|
||||
$travel->additionalServices = [60 => $autoBookBoard];
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$participant = new ParticipantDto();
|
||||
$participant->index = 0;
|
||||
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
||||
$participant->board = [$autoBookBoard];
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
$handler = new ParticipantBoardFieldHandler();
|
||||
$handler->processField([], $bookingDto, 0);
|
||||
|
||||
$this->assertSame([60], $participant->autoBookOptOutBoardIds);
|
||||
$this->assertSame([], $participant->board);
|
||||
}
|
||||
|
||||
public function testDeselectMandatoryAutoBookBoardDoesNotAddOptOutId(): void
|
||||
{
|
||||
$mandatoryAutoBookBoard = new Service();
|
||||
$mandatoryAutoBookBoard->id = 61;
|
||||
$mandatoryAutoBookBoard->subType = Constants::TOKEN_BOARD;
|
||||
$mandatoryAutoBookBoard->label = 'Mandatory Auto Book Board';
|
||||
$mandatoryAutoBookBoard->mandatory = true;
|
||||
$mandatoryAutoBookBoard->autoBook = true;
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('+30 days');
|
||||
$travel->dateTo = new \DateTimeImmutable('+37 days');
|
||||
$travel->additionalServices = [61 => $mandatoryAutoBookBoard];
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$participant = new ParticipantDto();
|
||||
$participant->index = 0;
|
||||
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
||||
$participant->board = [$mandatoryAutoBookBoard];
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
$handler = new ParticipantBoardFieldHandler();
|
||||
$handler->processField([], $bookingDto, 0);
|
||||
|
||||
$this->assertSame([], $participant->autoBookOptOutBoardIds);
|
||||
}
|
||||
|
||||
public function testReselectAutoBookBoardRemovesOptOutId(): void
|
||||
{
|
||||
$autoBookBoard = new Service();
|
||||
$autoBookBoard->id = 62;
|
||||
$autoBookBoard->subType = Constants::TOKEN_BOARD;
|
||||
$autoBookBoard->label = 'Auto Book Board';
|
||||
$autoBookBoard->autoBook = true;
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('+30 days');
|
||||
$travel->dateTo = new \DateTimeImmutable('+37 days');
|
||||
$travel->additionalServices = [62 => $autoBookBoard];
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$participant = new ParticipantDto();
|
||||
$participant->index = 0;
|
||||
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
||||
$participant->autoBookOptOutBoardIds = [62];
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
$handler = new ParticipantBoardFieldHandler();
|
||||
$handler->processField(['board' => ['62']], $bookingDto, 0);
|
||||
|
||||
$this->assertSame([], $participant->autoBookOptOutBoardIds);
|
||||
$this->assertCount(1, $participant->board);
|
||||
$this->assertSame(62, $participant->board[0]->id);
|
||||
}
|
||||
}
|
||||
@@ -91,6 +91,7 @@ class ParticipantFieldOptionsProviderMandatoryServiceTest extends TestCase
|
||||
$nonMandatoryService->available = 10;
|
||||
$nonMandatoryService->price = 10.0;
|
||||
$nonMandatoryService->mandatory = false;
|
||||
$nonMandatoryService->autoBook = true;
|
||||
|
||||
$travel = $this->createTravelWithAdditionalServices([$nonMandatoryService]);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Form\Service;
|
||||
|
||||
use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\ParticipantRentalsFieldHandler;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParticipantRentalsFieldHandlerTest extends TestCase
|
||||
{
|
||||
public function testDeselectAutoBookRentalAddsOptOutId(): void
|
||||
{
|
||||
$skiPass = $this->createSkiPass(70);
|
||||
$autoBookRental = $this->createRental(71, autoBook: true, mandatory: false);
|
||||
$bookingDto = $this->createBookingDtoWithSkiPassAndRental($skiPass, $autoBookRental);
|
||||
$participant = $bookingDto->participants[0];
|
||||
$participant->rentals = [$autoBookRental];
|
||||
|
||||
$handler = new ParticipantRentalsFieldHandler();
|
||||
$handler->processField([], $bookingDto, 0);
|
||||
|
||||
$this->assertSame([71], $participant->autoBookOptOutRentalIds);
|
||||
$this->assertSame([], $participant->rentals);
|
||||
}
|
||||
|
||||
public function testDeselectMandatoryAutoBookRentalDoesNotAddOptOutId(): void
|
||||
{
|
||||
$skiPass = $this->createSkiPass(72);
|
||||
$mandatoryAutoBookRental = $this->createRental(73, autoBook: true, mandatory: true);
|
||||
$bookingDto = $this->createBookingDtoWithSkiPassAndRental($skiPass, $mandatoryAutoBookRental);
|
||||
$participant = $bookingDto->participants[0];
|
||||
$participant->rentals = [$mandatoryAutoBookRental];
|
||||
|
||||
$handler = new ParticipantRentalsFieldHandler();
|
||||
$handler->processField([], $bookingDto, 0);
|
||||
|
||||
$this->assertSame([], $participant->autoBookOptOutRentalIds);
|
||||
}
|
||||
|
||||
public function testReselectAutoBookRentalRemovesOptOutId(): void
|
||||
{
|
||||
$skiPass = $this->createSkiPass(74);
|
||||
$autoBookRental = $this->createRental(75, autoBook: true, mandatory: false);
|
||||
$bookingDto = $this->createBookingDtoWithSkiPassAndRental($skiPass, $autoBookRental);
|
||||
$participant = $bookingDto->participants[0];
|
||||
$participant->autoBookOptOutRentalIds = [75];
|
||||
|
||||
$handler = new ParticipantRentalsFieldHandler();
|
||||
$handler->processField(['rentals' => ['75']], $bookingDto, 0);
|
||||
|
||||
$this->assertSame([], $participant->autoBookOptOutRentalIds);
|
||||
$this->assertCount(1, $participant->rentals);
|
||||
$this->assertSame(75, $participant->rentals[0]->id);
|
||||
}
|
||||
|
||||
private function createBookingDtoWithSkiPassAndRental(Service $skiPass, Service $rental): BookingDto
|
||||
{
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('2030-01-01');
|
||||
$travel->dateTo = new \DateTimeImmutable('2030-01-08');
|
||||
$travel->additionalServices = [
|
||||
$skiPass->id => $skiPass,
|
||||
$rental->id => $rental,
|
||||
];
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$participant = new ParticipantDto();
|
||||
$participant->index = 0;
|
||||
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
||||
$participant->skiPass = $skiPass;
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
return $bookingDto;
|
||||
}
|
||||
|
||||
private function createSkiPass(int $id): Service
|
||||
{
|
||||
$service = new Service();
|
||||
$service->id = $id;
|
||||
$service->subType = Constants::TOKEN_SKI_PASS;
|
||||
$service->label = 'Ski Pass';
|
||||
$service->dateFrom = new \DateTimeImmutable('2030-01-01');
|
||||
$service->dateTo = new \DateTimeImmutable('2030-01-07');
|
||||
|
||||
return $service;
|
||||
}
|
||||
|
||||
private function createRental(int $id, bool $autoBook, bool $mandatory): Service
|
||||
{
|
||||
$service = new Service();
|
||||
$service->id = $id;
|
||||
$service->subType = 'VER';
|
||||
$service->label = 'Rental';
|
||||
$service->autoBook = $autoBook;
|
||||
$service->mandatory = $mandatory;
|
||||
$service->dateFrom = new \DateTimeImmutable('2030-01-01');
|
||||
$service->dateTo = new \DateTimeImmutable('2030-01-07');
|
||||
|
||||
return $service;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Form\Service;
|
||||
|
||||
use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\ParticipantSkiPassFieldHandler;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParticipantSkiPassFieldHandlerTest extends TestCase
|
||||
{
|
||||
public function testDeselectAutoBookSkiPassAddsOptOutId(): void
|
||||
{
|
||||
$autoBookSkiPass = $this->createSkiPass(31, autoBook: true, mandatory: false);
|
||||
$bookingDto = $this->createBookingDtoWithSkiPass($autoBookSkiPass);
|
||||
$participant = $bookingDto->participants[0];
|
||||
$participant->skiPass = $autoBookSkiPass;
|
||||
|
||||
$handler = new ParticipantSkiPassFieldHandler();
|
||||
$handler->processField([], $bookingDto, 0);
|
||||
|
||||
$this->assertSame([31], $participant->autoBookOptOutSkiPassIds);
|
||||
$this->assertNull($participant->skiPass);
|
||||
}
|
||||
|
||||
public function testDeselectMandatoryAutoBookSkiPassDoesNotAddOptOutId(): void
|
||||
{
|
||||
$mandatoryAutoBookSkiPass = $this->createSkiPass(32, autoBook: true, mandatory: true);
|
||||
$bookingDto = $this->createBookingDtoWithSkiPass($mandatoryAutoBookSkiPass);
|
||||
$participant = $bookingDto->participants[0];
|
||||
$participant->skiPass = $mandatoryAutoBookSkiPass;
|
||||
|
||||
$handler = new ParticipantSkiPassFieldHandler();
|
||||
$handler->processField([], $bookingDto, 0);
|
||||
|
||||
$this->assertSame([], $participant->autoBookOptOutSkiPassIds);
|
||||
}
|
||||
|
||||
public function testReselectAutoBookSkiPassRemovesOptOutId(): void
|
||||
{
|
||||
$autoBookSkiPass = $this->createSkiPass(33, autoBook: true, mandatory: false);
|
||||
$bookingDto = $this->createBookingDtoWithSkiPass($autoBookSkiPass);
|
||||
$participant = $bookingDto->participants[0];
|
||||
$participant->autoBookOptOutSkiPassIds = [33];
|
||||
|
||||
$handler = new ParticipantSkiPassFieldHandler();
|
||||
$handler->processField(['skiPass' => '33'], $bookingDto, 0);
|
||||
|
||||
$this->assertSame([], $participant->autoBookOptOutSkiPassIds);
|
||||
$this->assertNotNull($participant->skiPass);
|
||||
$this->assertSame(33, $participant->skiPass?->id);
|
||||
}
|
||||
|
||||
private function createBookingDtoWithSkiPass(Service $skiPass): BookingDto
|
||||
{
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('+30 days');
|
||||
$travel->dateTo = new \DateTimeImmutable('+37 days');
|
||||
$travel->additionalServices = [$skiPass->id => $skiPass];
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$participant = new ParticipantDto();
|
||||
$participant->index = 0;
|
||||
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
return $bookingDto;
|
||||
}
|
||||
|
||||
private function createSkiPass(int $id, bool $autoBook, bool $mandatory): Service
|
||||
{
|
||||
$service = new Service();
|
||||
$service->id = $id;
|
||||
$service->subType = Constants::TOKEN_SKI_PASS;
|
||||
$service->label = 'Ski Pass';
|
||||
$service->autoBook = $autoBook;
|
||||
$service->mandatory = $mandatory;
|
||||
$service->dateFrom = new \DateTimeImmutable('+30 days');
|
||||
$service->dateTo = new \DateTimeImmutable('+36 days');
|
||||
|
||||
return $service;
|
||||
}
|
||||
}
|
||||
@@ -189,6 +189,299 @@ class BookingServiceBabyTest extends TestCase
|
||||
$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();
|
||||
@@ -199,6 +492,86 @@ class BookingServiceBabyTest extends TestCase
|
||||
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>
|
||||
*/
|
||||
@@ -214,4 +587,176 @@ class BookingServiceBabyTest extends TestCase
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user