feat: upgrade phpunit to 12.5
This commit is contained in:
@@ -19,23 +19,25 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BookingConfiguratorBabyTest extends TestCase
|
||||
{
|
||||
private BookingConfigurator $bookingService;
|
||||
private ?BookingConfigurator $bookingService = null;
|
||||
private ParticipantEligibilityChecker $participantEligibilityService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$this->participantEligibilityService = $this->createMock(ParticipantEligibilityChecker::class);
|
||||
$bookingStatusRuleRegistry = $this->createMock(BookingStatusRuleRegistry::class);
|
||||
$bookingStatusRuleRegistry->method('evaluateStatus')->willReturn('F');
|
||||
$agencyLoader = $this->createMock(AgencyLoader::class);
|
||||
$this->participantEligibilityService = $this->createStub(ParticipantEligibilityChecker::class);
|
||||
}
|
||||
|
||||
$this->bookingService = new BookingConfigurator(
|
||||
$this->createMock(BookingSessionManager::class),
|
||||
$travelDataService,
|
||||
private function bookingService(): BookingConfigurator
|
||||
{
|
||||
$bookingStatusRuleRegistry = $this->createStub(BookingStatusRuleRegistry::class);
|
||||
$bookingStatusRuleRegistry->method('evaluateStatus')->willReturn('F');
|
||||
|
||||
return $this->bookingService ??= new BookingConfigurator(
|
||||
$this->createStub(BookingSessionManager::class),
|
||||
$this->createStub(TravelDataProvider::class),
|
||||
$this->participantEligibilityService,
|
||||
$bookingStatusRuleRegistry,
|
||||
$agencyLoader,
|
||||
$this->createStub(AgencyLoader::class),
|
||||
'F' // default booking status
|
||||
);
|
||||
}
|
||||
@@ -52,7 +54,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
$participant->additionalServices = [];
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertEmpty($participant->additionalServices, 'Mandatory services should not be preselected for baby participants');
|
||||
}
|
||||
@@ -69,7 +71,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
$participant->additionalServices = [];
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertEmpty($participant->additionalServices, 'Mandatory services should not be preselected for participants at BABY_MAX_AGE');
|
||||
}
|
||||
@@ -91,7 +93,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertNotEmpty($participant->additionalServices, 'Mandatory services should be preselected for non-baby participants');
|
||||
$this->assertCount(1, $participant->additionalServices);
|
||||
@@ -115,7 +117,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertNotEmpty($participant->additionalServices, 'Mandatory services should be preselected for adult participants');
|
||||
$this->assertCount(1, $participant->additionalServices);
|
||||
@@ -123,6 +125,8 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
|
||||
public function testPreselectMandatoryServicesHandlesMixedParticipants(): void
|
||||
{
|
||||
$this->participantEligibilityService = $this->createMock(ParticipantEligibilityChecker::class);
|
||||
|
||||
$travel = $this->createTravelWithMandatoryServices();
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
|
||||
@@ -146,7 +150,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->with($bookingDto, 1) // Only called for adult
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertEmpty($babyParticipant->additionalServices, 'Baby should not have mandatory services preselected');
|
||||
$this->assertNotEmpty($adultParticipant->additionalServices, 'Adult should have mandatory services preselected');
|
||||
@@ -164,7 +168,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
$participant->additionalServices = [];
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertEmpty($participant->additionalServices, 'Mandatory services should not be preselected for newborn babies');
|
||||
}
|
||||
@@ -186,7 +190,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
$participant->additionalServices = [];
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($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');
|
||||
@@ -207,7 +211,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertCount(1, $participant->additionalServices);
|
||||
$this->assertSame('Auto Book Service', $participant->additionalServices[0]->label);
|
||||
@@ -229,7 +233,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertEmpty($participant->additionalServices);
|
||||
}
|
||||
@@ -250,7 +254,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertCount(1, $participant->additionalServices);
|
||||
$this->assertSame('Mandatory And Auto Book Service', $participant->additionalServices[0]->label);
|
||||
@@ -270,7 +274,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertNotNull($participant->skiPass);
|
||||
$this->assertSame('Auto Book Ski Pass', $participant->skiPass?->label);
|
||||
@@ -291,7 +295,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertNull($participant->skiPass);
|
||||
}
|
||||
@@ -311,7 +315,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertNotNull($participant->skiPass);
|
||||
$this->assertSame('Mandatory And Auto Book Ski Pass', $participant->skiPass?->label);
|
||||
@@ -331,7 +335,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertCount(1, $participant->board);
|
||||
$this->assertSame('Auto Book Board', $participant->board[0]->label);
|
||||
@@ -352,7 +356,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertSame([], $participant->board);
|
||||
}
|
||||
@@ -372,7 +376,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertCount(1, $participant->board);
|
||||
$this->assertSame('Mandatory And Auto Book Board', $participant->board[0]->label);
|
||||
@@ -393,7 +397,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertCount(1, $participant->rentals);
|
||||
$this->assertSame('Auto Book Rental', $participant->rentals[0]->label);
|
||||
@@ -415,7 +419,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertSame([], $participant->rentals);
|
||||
}
|
||||
@@ -436,7 +440,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertCount(1, $participant->rentals);
|
||||
$this->assertSame('Mandatory And Auto Book Rental', $participant->rentals[0]->label);
|
||||
@@ -456,7 +460,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertSame([], $participant->rentals);
|
||||
}
|
||||
@@ -480,7 +484,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertSame([], $participant->rentals);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user