feat: upgrade phpunit to 12.5
This commit is contained in:
+35
-19
@@ -15,31 +15,35 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestCase
|
||||
{
|
||||
private ParticipantTransportationDiscountReplacementFieldHandler $handler;
|
||||
private ?ParticipantTransportationDiscountReplacementFieldHandler $handler = null;
|
||||
private ServiceAvailabilityCalculator $serviceAvailabilityCalculator;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||
$this->handler = new ParticipantTransportationDiscountReplacementFieldHandler(
|
||||
$this->serviceAvailabilityCalculator = $this->createStub(ServiceAvailabilityCalculator::class);
|
||||
}
|
||||
|
||||
private function handler(): ParticipantTransportationDiscountReplacementFieldHandler
|
||||
{
|
||||
return $this->handler ??= new ParticipantTransportationDiscountReplacementFieldHandler(
|
||||
$this->serviceAvailabilityCalculator
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetFieldName(): void
|
||||
{
|
||||
$this->assertSame('transportationDiscountReplacement', $this->handler->getFieldName());
|
||||
$this->assertSame('transportationDiscountReplacement', $this->handler()->getFieldName());
|
||||
}
|
||||
|
||||
public function testGetDependencies(): void
|
||||
{
|
||||
$this->assertSame(['transportationOutbound', 'transportationInbound'], $this->handler->getDependencies());
|
||||
$this->assertSame(['transportationOutbound', 'transportationInbound'], $this->handler()->getDependencies());
|
||||
}
|
||||
|
||||
public function testShouldProcessAlwaysReturnsTrue(): void
|
||||
{
|
||||
$this->assertTrue($this->handler->shouldProcess([], BookingDto::MODE_CREATE, 0));
|
||||
$this->assertTrue($this->handler->shouldProcess(['some' => 'data'], BookingDto::MODE_EDIT, 5));
|
||||
$this->assertTrue($this->handler()->shouldProcess([], BookingDto::MODE_CREATE, 0));
|
||||
$this->assertTrue($this->handler()->shouldProcess(['some' => 'data'], BookingDto::MODE_EDIT, 5));
|
||||
}
|
||||
|
||||
public function testProcessFieldReplacesDiscountedWithRegularWhenInboundIsBus(): void
|
||||
@@ -62,7 +66,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
$submittedData = [];
|
||||
|
||||
// Process
|
||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
||||
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||
|
||||
// Assert outbound was replaced with regular PKW
|
||||
$this->assertSame($regularPkw->id, $participant->transportationOutbound->id);
|
||||
@@ -79,6 +83,8 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
|
||||
public function testProcessFieldRestoresDiscountedPkwWhenInboundChangesToPkw(): void
|
||||
{
|
||||
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||
|
||||
// Setup services
|
||||
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
||||
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
||||
@@ -104,7 +110,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
$submittedData = [];
|
||||
|
||||
// Process
|
||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
||||
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||
|
||||
// Assert outbound was replaced with discounted PKW
|
||||
$this->assertSame($discountedPkw->id, $participant->transportationOutbound->id);
|
||||
@@ -120,6 +126,8 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
|
||||
public function testProcessFieldDoesNotRestoreDiscountWhenUnavailable(): void
|
||||
{
|
||||
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||
|
||||
// Setup services
|
||||
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
||||
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
||||
@@ -145,7 +153,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
$submittedData = [];
|
||||
|
||||
// Process
|
||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
||||
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||
|
||||
// Assert outbound remains regular PKW
|
||||
$this->assertSame($regularPkw, $participant->transportationOutbound);
|
||||
@@ -174,7 +182,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
$submittedData = [];
|
||||
|
||||
// Process
|
||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
||||
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||
|
||||
// Assert outbound remains BUS (no replacement)
|
||||
$this->assertSame($busOutbound, $participant->transportationOutbound);
|
||||
@@ -203,7 +211,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
$submittedData = [];
|
||||
|
||||
// Process
|
||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
||||
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||
|
||||
// Assert outbound remains regular PKW (already correct)
|
||||
$this->assertSame($regularPkw, $participant->transportationOutbound);
|
||||
@@ -232,7 +240,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
$submittedData = [];
|
||||
|
||||
// Process
|
||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
||||
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||
|
||||
// Assert outbound remains discounted PKW (already optimal)
|
||||
$this->assertSame($discountedPkw, $participant->transportationOutbound);
|
||||
@@ -256,7 +264,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
$submittedData = [];
|
||||
|
||||
// Process - should handle gracefully
|
||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
||||
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||
|
||||
// Assert no error and no notification
|
||||
$this->assertNull($participant->transportationOutbound);
|
||||
@@ -265,6 +273,8 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
|
||||
public function testProcessFieldHandlesNullInbound(): void
|
||||
{
|
||||
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||
|
||||
// Setup services
|
||||
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
||||
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
||||
@@ -289,7 +299,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
$submittedData = [];
|
||||
|
||||
// Process - null inbound is treated as non-BUS, should attempt restoration
|
||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
||||
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||
|
||||
// Assert outbound was replaced with discounted PKW
|
||||
$this->assertSame($discountedPkw->id, $participant->transportationOutbound->id);
|
||||
@@ -306,7 +316,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
$submittedData = [];
|
||||
|
||||
// Process - should handle gracefully
|
||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
||||
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||
|
||||
// Should not throw error
|
||||
$this->expectNotToPerformAssertions();
|
||||
@@ -314,6 +324,8 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
|
||||
public function testProcessFieldSkipsDiscountRestorationForBabyParticipant(): void
|
||||
{
|
||||
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||
|
||||
// Setup services
|
||||
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
||||
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
||||
@@ -339,7 +351,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
$submittedData = [];
|
||||
|
||||
// Process
|
||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
||||
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||
|
||||
// Assert outbound remains regular PKW (no discount restoration for babies)
|
||||
$this->assertSame($regularPkw->id, $participant->transportationOutbound->id);
|
||||
@@ -350,6 +362,8 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
|
||||
public function testProcessFieldSkipsDiscountRestorationForTwoYearOldParticipant(): void
|
||||
{
|
||||
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||
|
||||
// Setup services
|
||||
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
||||
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
||||
@@ -375,7 +389,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
$submittedData = [];
|
||||
|
||||
// Process
|
||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
||||
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||
|
||||
// Assert outbound remains regular PKW
|
||||
$this->assertSame($regularPkw->id, $participant->transportationOutbound->id);
|
||||
@@ -386,6 +400,8 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
|
||||
public function testProcessFieldRestoresDiscountForThreeYearOldParticipant(): void
|
||||
{
|
||||
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||
|
||||
// Setup services
|
||||
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
||||
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
||||
@@ -414,7 +430,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
||||
$submittedData = [];
|
||||
|
||||
// Process
|
||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
||||
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||
|
||||
// Assert outbound was replaced with discounted PKW (3-year-old is eligible)
|
||||
$this->assertSame($discountedPkw->id, $participant->transportationOutbound->id);
|
||||
|
||||
Reference in New Issue
Block a user