fix: consider parking space availability
This commit is contained in:
1 parent
fafc60eba9
commit
b323c120f9
7 files changed
+237
-4
No files matched your search
@@ -135,6 +135,64 @@ class ParticipantFieldOptionsProviderMandatoryServiceTest extends TestCase
|
||||
$this->assertSame('Parkplatz (€12,50)', $options['label']);
|
||||
}
|
||||
|
||||
public function testParkingIsReadonlyWhenSoldOut(): void
|
||||
{
|
||||
$parkingService = new Service();
|
||||
$parkingService->id = 3;
|
||||
$parkingService->label = 'Parkplatz';
|
||||
$parkingService->subType = Constants::TOKEN_PARKING;
|
||||
$parkingService->available = 0;
|
||||
$parkingService->price = 12.5;
|
||||
|
||||
$travel = $this->createTravelWithAdditionalServices([$parkingService]);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
|
||||
$participant = new ParticipantDto();
|
||||
$participant->index = 0;
|
||||
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
$serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||
$serviceAvailabilityCalculator->method('isServiceUnavailable')
|
||||
->with($parkingService->id, $bookingDto, 0)
|
||||
->willReturn(true);
|
||||
|
||||
$provider = new ParticipantFieldOptionsProvider(
|
||||
$serviceAvailabilityCalculator,
|
||||
$this->createMock(InsuranceManager::class),
|
||||
$this->createMock(BookingPriceCalculator::class),
|
||||
new ServiceLabelFormatter(),
|
||||
$this->createMock(TranslatorInterface::class)
|
||||
);
|
||||
|
||||
$options = $provider->getFieldOptions('parking', $bookingDto, 0);
|
||||
|
||||
$this->assertTrue($options['attr']['readonly']);
|
||||
$this->assertSame('ausgebucht', $options['attr']['data-tooltip']);
|
||||
}
|
||||
|
||||
public function testParkingIsNotReadonlyWhenAvailable(): void
|
||||
{
|
||||
$parkingService = new Service();
|
||||
$parkingService->id = 3;
|
||||
$parkingService->label = 'Parkplatz';
|
||||
$parkingService->subType = Constants::TOKEN_PARKING;
|
||||
$parkingService->available = 10;
|
||||
$parkingService->price = 12.5;
|
||||
|
||||
$travel = $this->createTravelWithAdditionalServices([$parkingService]);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
|
||||
$participant = new ParticipantDto();
|
||||
$participant->index = 0;
|
||||
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
$options = $this->provider->getFieldOptions('parking', $bookingDto, 0);
|
||||
|
||||
$this->assertArrayNotHasKey('attr', $options);
|
||||
}
|
||||
|
||||
public function testNullParticipantReturnsEmptyOptions(): void
|
||||
{
|
||||
$mandatoryService = $this->createMandatoryService(1, 'Ortstaxe');
|
||||
|
||||
Reference in new issue
Block a user