wip: modernized edit flow, fix insurance tier calculation
This commit is contained in:
@@ -14,7 +14,7 @@ use App\BusProNet\Model\Pickup;
|
||||
use App\BusProNet\Model\Room;
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingEditDto;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -210,29 +210,31 @@ class BookingDataProcessorTest extends TestCase
|
||||
$this->assertArrayNotHasKey('zustiege', $result);
|
||||
}
|
||||
|
||||
private function createCompleteFormData(): BookingEditDto
|
||||
private function createCompleteFormData(): BookingDto
|
||||
{
|
||||
$formData = new BookingEditDto($this->createMockBooking(), $this->createMockTravel());
|
||||
$formData->participants = [
|
||||
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
||||
$bookingDto->booking = $this->createMockBooking();
|
||||
$bookingDto->participants = [
|
||||
$this->createMockParticipantDto(0, 'F'),
|
||||
$this->createMockParticipantDto(1, 'F'),
|
||||
];
|
||||
|
||||
return $formData;
|
||||
return $bookingDto;
|
||||
}
|
||||
|
||||
private function createFormDataWithCanceledParticipant(): BookingEditDto
|
||||
private function createFormDataWithCanceledParticipant(): BookingDto
|
||||
{
|
||||
$formData = new BookingEditDto($this->createMockBooking(), $this->createMockTravel());
|
||||
$formData->participants = [
|
||||
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
||||
$bookingDto->booking = $this->createMockBooking();
|
||||
$bookingDto->participants = [
|
||||
$this->createMockParticipantDto(0, 'F'),
|
||||
$this->createMockParticipantDto(1, 'S'), // Canceled
|
||||
];
|
||||
|
||||
return $formData;
|
||||
return $bookingDto;
|
||||
}
|
||||
|
||||
private function createFormDataWithAdditionalServices(): BookingEditDto
|
||||
private function createFormDataWithAdditionalServices(): BookingDto
|
||||
{
|
||||
$formData = $this->createCompleteFormData();
|
||||
|
||||
@@ -243,7 +245,7 @@ class BookingDataProcessorTest extends TestCase
|
||||
return $formData;
|
||||
}
|
||||
|
||||
private function createFormDataWithTransportation(): BookingEditDto
|
||||
private function createFormDataWithTransportation(): BookingDto
|
||||
{
|
||||
$formData = $this->createCompleteFormData();
|
||||
|
||||
@@ -254,7 +256,7 @@ class BookingDataProcessorTest extends TestCase
|
||||
return $formData;
|
||||
}
|
||||
|
||||
private function createFormDataWithBusPickup(): BookingEditDto
|
||||
private function createFormDataWithBusPickup(): BookingDto
|
||||
{
|
||||
$formData = $this->createCompleteFormData();
|
||||
|
||||
@@ -267,7 +269,7 @@ class BookingDataProcessorTest extends TestCase
|
||||
return $formData;
|
||||
}
|
||||
|
||||
private function createFormDataWithNonBusTransportation(): BookingEditDto
|
||||
private function createFormDataWithNonBusTransportation(): BookingDto
|
||||
{
|
||||
$formData = $this->createCompleteFormData();
|
||||
|
||||
@@ -279,7 +281,7 @@ class BookingDataProcessorTest extends TestCase
|
||||
return $formData;
|
||||
}
|
||||
|
||||
private function createFormDataWithUnusedServices(): BookingEditDto
|
||||
private function createFormDataWithUnusedServices(): BookingDto
|
||||
{
|
||||
$formData = $this->createCompleteFormData();
|
||||
|
||||
@@ -289,7 +291,7 @@ class BookingDataProcessorTest extends TestCase
|
||||
return $formData;
|
||||
}
|
||||
|
||||
private function createFormDataWithUpdatedPersonalData(): BookingEditDto
|
||||
private function createFormDataWithUpdatedPersonalData(): BookingDto
|
||||
{
|
||||
$formData = $this->createCompleteFormData();
|
||||
|
||||
@@ -302,7 +304,7 @@ class BookingDataProcessorTest extends TestCase
|
||||
return $formData;
|
||||
}
|
||||
|
||||
private function createFormDataWithInactiveParticipant(): BookingEditDto
|
||||
private function createFormDataWithInactiveParticipant(): BookingDto
|
||||
{
|
||||
$formData = $this->createCompleteFormData();
|
||||
|
||||
@@ -318,7 +320,7 @@ class BookingDataProcessorTest extends TestCase
|
||||
return $formData;
|
||||
}
|
||||
|
||||
private function createFormDataForApplicantSync(): BookingEditDto
|
||||
private function createFormDataForApplicantSync(): BookingDto
|
||||
{
|
||||
$formData = $this->createCompleteFormData();
|
||||
|
||||
@@ -330,7 +332,7 @@ class BookingDataProcessorTest extends TestCase
|
||||
return $formData;
|
||||
}
|
||||
|
||||
private function createFormDataWithBankAccount(): BookingEditDto
|
||||
private function createFormDataWithBankAccount(): BookingDto
|
||||
{
|
||||
$formData = $this->createCompleteFormData();
|
||||
|
||||
@@ -345,7 +347,7 @@ class BookingDataProcessorTest extends TestCase
|
||||
return $formData;
|
||||
}
|
||||
|
||||
private function createFormDataWithoutBankAccount(): BookingEditDto
|
||||
private function createFormDataWithoutBankAccount(): BookingDto
|
||||
{
|
||||
$formData = $this->createCompleteFormData();
|
||||
$formData->booking->bankAccount = null;
|
||||
@@ -353,7 +355,7 @@ class BookingDataProcessorTest extends TestCase
|
||||
return $formData;
|
||||
}
|
||||
|
||||
private function createFormDataWithRooms(): BookingEditDto
|
||||
private function createFormDataWithRooms(): BookingDto
|
||||
{
|
||||
$formData = $this->createCompleteFormData();
|
||||
|
||||
@@ -371,7 +373,7 @@ class BookingDataProcessorTest extends TestCase
|
||||
return $formData;
|
||||
}
|
||||
|
||||
private function createFormDataWithoutExistingCommunication(): BookingEditDto
|
||||
private function createFormDataWithoutExistingCommunication(): BookingDto
|
||||
{
|
||||
$formData = $this->createCompleteFormData();
|
||||
|
||||
@@ -384,7 +386,7 @@ class BookingDataProcessorTest extends TestCase
|
||||
return $formData;
|
||||
}
|
||||
|
||||
private function createFormDataWithoutPickups(): BookingEditDto
|
||||
private function createFormDataWithoutPickups(): BookingDto
|
||||
{
|
||||
$formData = $this->createCompleteFormData();
|
||||
$formData->booking->pickupsOutbound = [];
|
||||
|
||||
@@ -6,8 +6,7 @@ namespace App\Tests\Form\Service\Condition;
|
||||
|
||||
use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\BookingEditDto;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Service\Condition\InsuranceMutabilityCondition;
|
||||
use Carbon\Carbon;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -35,7 +34,7 @@ class InsuranceMutabilityConditionTest extends TestCase
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('+10 days');
|
||||
|
||||
$bookingDto = new BookingCreateDto($travel, 123);
|
||||
$bookingDto = new BookingDto($travel, 123);
|
||||
|
||||
$result = $this->condition->evaluate($bookingDto, 0, []);
|
||||
|
||||
@@ -154,7 +153,7 @@ class InsuranceMutabilityConditionTest extends TestCase
|
||||
$this->assertStringContainsString('3', $result);
|
||||
}
|
||||
|
||||
private function createEditDto(\DateTimeImmutable $travelDate, \DateTimeImmutable $bookingDate): BookingEditDto
|
||||
private function createEditDto(\DateTimeImmutable $travelDate, \DateTimeImmutable $bookingDate): BookingDto
|
||||
{
|
||||
$booking = new Booking();
|
||||
$booking->bookingDate = $bookingDate;
|
||||
@@ -162,6 +161,9 @@ class InsuranceMutabilityConditionTest extends TestCase
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = $travelDate;
|
||||
|
||||
return new BookingEditDto($booking, $travel);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->booking = $booking;
|
||||
|
||||
return $bookingDto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace App\Tests\Form\Service;
|
||||
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\ParticipantInsuranceFieldHandler;
|
||||
use App\Service\InsuranceMatchingService;
|
||||
@@ -229,8 +229,8 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
||||
return $insurance;
|
||||
}
|
||||
|
||||
private function createMockBookingDto(): BookingCreateDto
|
||||
private function createMockBookingDto(): BookingDto
|
||||
{
|
||||
return $this->createMock(BookingCreateDto::class);
|
||||
return $this->createMock(BookingDto::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Tests\Form\Service;
|
||||
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\ParticipantLicensePlateFieldHandler;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -38,7 +38,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
public function testProcessFieldWithoutParticipant(): void
|
||||
{
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$submittedData = ['licensePlate' => 'AB-CD 123'];
|
||||
|
||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
||||
@@ -54,7 +54,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->licensePlate = 'AB-CD 123'; // Should be cleared
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$submittedData = ['licensePlate' => 'XY-ZZ 999'];
|
||||
@@ -70,7 +70,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->parking = true; // Parking selected
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$submittedData = ['licensePlate' => 'AB-CD 123'];
|
||||
@@ -86,7 +86,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->parking = true; // Parking selected
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$submittedData = ['licensePlate' => ''];
|
||||
@@ -102,7 +102,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->parking = true; // Parking selected
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$submittedData = ['licensePlate' => null];
|
||||
@@ -118,7 +118,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->parking = true; // Parking selected
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$submittedData = ['licensePlate' => ' AB-CD 123 '];
|
||||
@@ -134,7 +134,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->parking = true; // Parking selected
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$submittedData = ['licensePlate' => ' '];
|
||||
@@ -150,7 +150,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->parking = true; // Parking selected
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
// Test with integer value
|
||||
@@ -170,7 +170,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->parking = true; // Parking selected
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$submittedData = []; // No licensePlate field
|
||||
@@ -189,7 +189,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant2->parking = true;
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant1, $participant2];
|
||||
|
||||
$submittedData = ['licensePlate' => 'AB-CD 123'];
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace App\Tests\Service;
|
||||
use App\BusProNet\Model\Room;
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Model\RoomSelectionDto;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
@@ -38,7 +38,7 @@ class BookingPriceCalculatorServiceTest extends TestCase
|
||||
$roomSelection->roomId = 1;
|
||||
$roomSelection->quantity = 2; // 2 rooms selected
|
||||
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->roomSelections = [$roomSelection];
|
||||
|
||||
// Test the calculation
|
||||
@@ -70,7 +70,7 @@ class BookingPriceCalculatorServiceTest extends TestCase
|
||||
$roomSelection->roomId = 2;
|
||||
$roomSelection->quantity = 1; // 1 room selected
|
||||
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->roomSelections = [$roomSelection];
|
||||
|
||||
// Test the calculation
|
||||
@@ -112,7 +112,7 @@ class BookingPriceCalculatorServiceTest extends TestCase
|
||||
$doubleRoomSelection->roomId = 2;
|
||||
$doubleRoomSelection->quantity = 2; // 2 double rooms
|
||||
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->roomSelections = [$singleRoomSelection, $doubleRoomSelection];
|
||||
|
||||
// Test the calculation
|
||||
@@ -155,7 +155,7 @@ class BookingPriceCalculatorServiceTest extends TestCase
|
||||
$roomSelection->roomId = 1;
|
||||
$roomSelection->quantity = 1;
|
||||
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->roomSelections = [$roomSelection];
|
||||
|
||||
$result = $this->service->calculateRoomPricing($bookingDto);
|
||||
@@ -179,7 +179,7 @@ class BookingPriceCalculatorServiceTest extends TestCase
|
||||
$roomSelection->roomId = 1;
|
||||
$roomSelection->quantity = 0; // Zero quantity - not selected
|
||||
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->roomSelections = [$roomSelection];
|
||||
|
||||
$result = $this->service->calculateRoomPricing($bookingDto);
|
||||
@@ -212,7 +212,7 @@ class BookingPriceCalculatorServiceTest extends TestCase
|
||||
$participant->skiPass = $skiPass;
|
||||
$participant->courses = [$course];
|
||||
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$result = $this->service->calculateIndividualParticipantPrice($bookingDto, 0);
|
||||
@@ -234,7 +234,7 @@ class BookingPriceCalculatorServiceTest extends TestCase
|
||||
$participant->assignedRoomId = null; // No room assigned
|
||||
$participant->skiPass = $skiPass;
|
||||
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$result = $this->service->calculateIndividualParticipantPrice($bookingDto, 0);
|
||||
@@ -246,7 +246,7 @@ class BookingPriceCalculatorServiceTest extends TestCase
|
||||
public function testCalculateIndividualParticipantPriceForNonExistentParticipant(): void
|
||||
{
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [];
|
||||
|
||||
$result = $this->service->calculateIndividualParticipantPrice($bookingDto, 0);
|
||||
@@ -290,7 +290,7 @@ class BookingPriceCalculatorServiceTest extends TestCase
|
||||
$participant3 = new ParticipantDto();
|
||||
$participant3->assignedRoomId = null; // No room assigned
|
||||
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant1, $participant2, $participant3];
|
||||
|
||||
$result = $this->service->calculateAllParticipantIndividualPrices($bookingDto);
|
||||
@@ -308,7 +308,7 @@ class BookingPriceCalculatorServiceTest extends TestCase
|
||||
public function testCalculateAllParticipantIndividualPricesWithEmptyBooking(): void
|
||||
{
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [];
|
||||
|
||||
$result = $this->service->calculateAllParticipantIndividualPrices($bookingDto);
|
||||
|
||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Tests\Service;
|
||||
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
use App\Service\InsuranceMatchingService;
|
||||
@@ -254,10 +254,10 @@ class InsuranceMatchingServiceTest extends TestCase
|
||||
return $participant;
|
||||
}
|
||||
|
||||
private function createBooking(string $travelDateFrom, string $travelDateTo): BookingCreateDto
|
||||
private function createBooking(string $travelDateFrom, string $travelDateTo): BookingDto
|
||||
{
|
||||
$travel = $this->createTravel($travelDateFrom, $travelDateTo);
|
||||
$booking = new BookingCreateDto($travel, 1);
|
||||
$booking = new BookingDto($travel, 1);
|
||||
|
||||
return $booking;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user