Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e35a7ab881 | ||
|
|
00eaea57f6 | ||
|
|
fafc60eba9 | ||
|
|
bd2d8b58a3 | ||
|
|
52327864d6 |
No files matched your search
+1
-1
@@ -2,7 +2,7 @@ const {defineConfig} = require("cypress");
|
||||
|
||||
module.exports = defineConfig({
|
||||
e2e: {
|
||||
baseUrl: 'https://myep-next-booking.ddev.site',
|
||||
baseUrl: 'https://myep.ddev.site',
|
||||
supportFile: false,
|
||||
},
|
||||
});
|
||||
@@ -1,5 +1,7 @@
|
||||
# Body Dimensions Transition Plan (Stakeholder Draft)
|
||||
|
||||
> **STATUS (verified 2026-07-15): NOT IMPLEMENTED.** `src/Form/BodyDimensionsType.php` still declares `height`, `shoeSize`, and `weight` as `IntegerType` fields, and `src/Validator/Constraints/ParticipantValidator.php` has no regex/legacy-format handling — only numeric range checks. This plan has not been acted on.
|
||||
|
||||
## Goal
|
||||
|
||||
Prevent edit-form failures for existing bookings while we transition from legacy body-dimension values to a better long-term field model.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Booking Flow Reference
|
||||
|
||||
Last updated: 2026-04-16
|
||||
Last updated: 2026-07-15
|
||||
|
||||
This document traces the booking create and edit flows from controller entry point through to session/DTO state. It is intended as orientation for developers unfamiliar with the flow, not as a substitute for reading the code.
|
||||
|
||||
@@ -35,7 +35,7 @@ Step 1 (room selection)
|
||||
|
||||
### Entry / Bootstrap
|
||||
|
||||
`BookingExceptionHandlerTrait::getOrCreateBookingCreateDto()` is called by every step controller. If no DTO exists in session, it calls `BookingConfigurator::startFreshBooking()` which loads travel data and initialises a fresh `BookingDto`.
|
||||
`AbstractBookingCreateController::loadBookingCreateDto()` is called by every step controller and delegates to `BookingSessionManager::getOrCreateBookingCreateDto()`. If no DTO exists in session, `BookingConfigurator::startFreshBooking()` loads travel data and initialises a fresh `BookingDto`.
|
||||
|
||||
### Step 1 — Room Selection
|
||||
|
||||
@@ -62,7 +62,7 @@ HTMX refresh (`/bookings/create/refresh`): processes the form without validation
|
||||
1. Load DTO from session (or redirect to Step 1 if missing)
|
||||
2. `TravelDataProvider::enrichWithFreshAvailabilities()` — refreshes room availability
|
||||
3. `ensureCorrectNumberOfParticipants()` — syncs the `BookingDto::participants` array length with the room selections (e.g., 2× double room → 4 participants). Preserves existing participant data for slots that still exist.
|
||||
4. `ParticipantDataPrefiller::shouldPrepopulateApplicant()` + `prepopulateApplicantFromUser()` — prefills participant[0] from user profile on first visit
|
||||
4. `ParticipantDataPrefiller::shouldPrefillApplicant()` + `prefillApplicantFromUser()` — prefills participant[0] from user profile on first visit
|
||||
5. `RoomAssigner::validateAndResetInvalidAssignments()` — clears any room assignments that no longer match the current room selection (handles back-navigation from Step 2 → Step 1 → Step 2)
|
||||
6. `RoomAssigner::assignRoomsIfNeeded()` — auto-assigns participants to rooms
|
||||
7. `BookingConfigurator::preselectDefaultServices()` — selects mandatory and auto-book services for all participants
|
||||
|
||||
@@ -125,8 +125,6 @@ Delete Draft on Success
|
||||
|
||||
```
|
||||
src/
|
||||
├── Admin/ # EasyAdmin custom fields
|
||||
│ └── Field/JsonDataField.php
|
||||
├── BusProNet/ # BusProNet API integration layer
|
||||
│ ├── ApiClient.php # Main API client
|
||||
│ ├── Constants.php # Service tokens and constants
|
||||
@@ -134,12 +132,12 @@ src/
|
||||
│ ├── DataProvider/ # Data providers (countries)
|
||||
│ ├── Exception/ # API-specific exceptions
|
||||
│ ├── Form/ # Form choice loaders
|
||||
│ ├── Model/ # Data models (39 classes)
|
||||
│ ├── Model/ # Data models (41 classes)
|
||||
│ ├── Traits/ # Shared traits
|
||||
│ ├── Utility/ # Helper utilities
|
||||
│ ├── XmlLoader/ # Cached XML file loaders
|
||||
│ └── XmlParser/ # XML response parsers (28 classes)
|
||||
├── Command/ # CLI commands (9 commands)
|
||||
│ └── XmlParser/ # XML response parsers (29 classes)
|
||||
├── Command/ # CLI commands (15 commands)
|
||||
├── Controller/ # HTTP controllers
|
||||
│ ├── Account/ # Account management
|
||||
│ ├── Admin/ # EasyAdmin controllers
|
||||
@@ -151,6 +149,7 @@ src/
|
||||
│ ├── RegistrationController.php
|
||||
│ ├── ResetPasswordController.php
|
||||
│ └── SecurityController.php
|
||||
├── Email/ # Transactional email builders
|
||||
├── Entity/ # Doctrine entities
|
||||
│ ├── User.php
|
||||
│ ├── LogEntry.php
|
||||
@@ -160,16 +159,19 @@ src/
|
||||
├── Form/ # Form system
|
||||
│ ├── Model/ # DTOs (BookingDto, ParticipantDto, etc.)
|
||||
│ ├── Service/ # Field handlers & conditions
|
||||
│ │ └── Condition/ # 22+ condition classes
|
||||
│ │ └── Condition/ # 25 condition classes
|
||||
│ ├── DataTransformer/ # Form data transformers
|
||||
│ └── Extension/ # Form extensions (XSS protection)
|
||||
├── Htmx/ # HTMX utilities
|
||||
├── Logger/ # Custom Monolog handlers/processors
|
||||
├── Menu/ # Navigation menu builders
|
||||
├── Message/ # Messenger message classes
|
||||
├── MessageHandler/ # Messenger message handlers
|
||||
├── Model/ # Application models
|
||||
├── Repository/ # Doctrine repositories
|
||||
├── Security/ # Authentication & authorization
|
||||
│ └── Voter/ # Custom voters
|
||||
├── Service/ # Business logic services (21 services)
|
||||
├── Service/ # Business logic services (43 services)
|
||||
├── Twig/ # Template extensions
|
||||
└── Validator/ # Custom validation constraints
|
||||
└── Constraints/ # Constraint classes
|
||||
@@ -196,7 +198,7 @@ assets/
|
||||
├── app.js # Main entry point
|
||||
├── bootstrap.js # Stimulus initialization
|
||||
├── loading.js # HTMX loading indicator
|
||||
├── controllers/ # Stimulus controllers (10)
|
||||
├── controllers/ # Stimulus controllers (14)
|
||||
├── styles/ # TailwindCSS styles
|
||||
│ ├── app.css # Main stylesheet
|
||||
│ └── components/ # Component styles
|
||||
@@ -1001,6 +1003,10 @@ public function deleteExpiredDrafts(): int;
|
||||
| `toast_controller` | Toast notifications via Toastify |
|
||||
| `tooltip_controller` | Tooltips via Tippy.js |
|
||||
| `backbutton_controller` | Browser back navigation |
|
||||
| `data_layer_controller` | Pushes analytics events to the data layer |
|
||||
| `mobilenav_controller` | Mobile navigation menu |
|
||||
| `password_reveal_controller` | Show/hide password input |
|
||||
| `sidebar_menu_controller` | Sidebar menu state |
|
||||
|
||||
### 9.2 HTMX Integration
|
||||
|
||||
@@ -1121,6 +1127,22 @@ php bin/console app:bpn:xml-sync [--force|-f] [--dry-run]
|
||||
|
||||
Synchronizes XML export files from remote SFTP. Invalidates caches on completion.
|
||||
|
||||
#### app:bpn:refresh-travel-snapshot
|
||||
|
||||
```bash
|
||||
php bin/console app:bpn:refresh-travel-snapshot
|
||||
```
|
||||
|
||||
Refreshes active travel snapshots using extended availability data.
|
||||
|
||||
#### app:bpn:xml-cache-invalidate
|
||||
|
||||
```bash
|
||||
php bin/console app:bpn:xml-cache-invalidate
|
||||
```
|
||||
|
||||
Invalidates BPN XML caches when local `uebertragung.info` changes.
|
||||
|
||||
### 10.2 Maintenance Commands
|
||||
|
||||
#### app:draft:cleanup
|
||||
@@ -1185,6 +1207,22 @@ Creates or deletes the Mailjet `unsub` callback for `POST /webhooks/mailjet/news
|
||||
- `register` prints the API response payload so you can note the callback ID.
|
||||
- `remove` and `deactivate` require the callback ID returned by Mailjet.
|
||||
|
||||
#### app:db:anonymize
|
||||
|
||||
```bash
|
||||
php bin/console app:db:anonymize
|
||||
```
|
||||
|
||||
Anonymizes personal data in the local database.
|
||||
|
||||
#### app:log-entry:backfill-error-codes
|
||||
|
||||
```bash
|
||||
php bin/console app:log-entry:backfill-error-codes
|
||||
```
|
||||
|
||||
Backfills the `error_code` column from extra data in existing log entries.
|
||||
|
||||
### 10.3 Setup Commands
|
||||
|
||||
#### app:crypto:generate-keys
|
||||
@@ -1288,7 +1326,7 @@ This section documents known API behaviors and the solutions implemented.
|
||||
|
||||
**Solution:** Automatic retry with configurable attempts (default: 3) and delay (default: 1s).
|
||||
|
||||
**Location:** `src/BusProNet/ApiClient.php:625-659`
|
||||
**Location:** `src/BusProNet/ApiClient.php:646` (`executeWithRetry`)
|
||||
|
||||
```php
|
||||
private function executeWithRetry(callable $operation, ?string $type = null): mixed
|
||||
@@ -1347,7 +1385,7 @@ public function shouldProcess(...): bool
|
||||
|
||||
**Solution:** Exclude `personId` and `addressId` from create mode payload.
|
||||
|
||||
**Location:** `src/BusProNet/DataProcessor/BookingPayloadBuilder.php:247-249`
|
||||
**Location:** `src/BusProNet/DataProcessor/BookingPayloadBuilder.php:275,313`
|
||||
|
||||
### 13.6 Personal Data Mutability Flag
|
||||
|
||||
@@ -1365,7 +1403,7 @@ public function shouldProcess(...): bool
|
||||
|
||||
**Solution:** Inject synthetic option with ID '0' that satisfies validation but is excluded from API transmission.
|
||||
|
||||
**Location:** `src/BusProNet/Model/Insurance.php:19-26`
|
||||
**Location:** `src/BusProNet/Model/Insurance.php:26` (constant), `:201` (`isNoInsurance()`)
|
||||
|
||||
```php
|
||||
public const NO_INSURANCE_ID = '0';
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\BusProNet\DataProcessor;
|
||||
|
||||
use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\BusProNet\Utility\DirectionMapper;
|
||||
use App\BusProNet\XmlLoader\AgencyLoader;
|
||||
@@ -362,12 +363,97 @@ class BookingDataProcessor
|
||||
*/
|
||||
public function createBookingRequestPayload(BookingDto $bookingDto, string $bookingType): array
|
||||
{
|
||||
// Re-validate each participant's insurance against current eligibility (price tier,
|
||||
// family constraint, etc.) before submission - selections can go stale between the
|
||||
// moment they were chosen and final submission, since users can freely revisit
|
||||
// earlier steps and change composition/services without ever re-opening the
|
||||
// insurance field. Must run before the applicant-to-dependents propagation below,
|
||||
// so that propagation is based on an already-corrected applicant selection.
|
||||
$this->reconcileInsuranceEligibility($bookingDto);
|
||||
|
||||
// Apply bulk or family insurance if applicable (modifies DTO in place)
|
||||
$this->applyApplicantInsuranceToParticipants($bookingDto);
|
||||
|
||||
return $this->payloadBuilder->buildCreatePayload($bookingDto, $bookingType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-validates every participant's currently selected insurance against present-day
|
||||
* eligibility (price tier, family constraint, age, travel/booking dates, duration) and
|
||||
* corrects any selection that's gone stale.
|
||||
*
|
||||
* Insurance eligibility is normally re-checked when a participant's own card is
|
||||
* resubmitted (see ParticipantInsuranceFieldHandler::processField()), but nothing forces
|
||||
* that to happen again if the user changes composition or services on an earlier step
|
||||
* after insurance was already chosen, then jumps straight to submission. Left unchecked,
|
||||
* a stale insurance ID (e.g. a family-tariff price tier that no longer matches the
|
||||
* current total booking price) would reach the BPN API and be rejected as a mismatch.
|
||||
*
|
||||
* Mirrors the reassign-or-clear logic already established in
|
||||
* ParticipantInsuranceFieldHandler for the resubmission case, applied here across all
|
||||
* participants right before the payload is built.
|
||||
*/
|
||||
private function reconcileInsuranceEligibility(BookingDto $bookingDto): bool
|
||||
{
|
||||
$selectableInsurances = $this->insuranceService->getSelectableInsurances($bookingDto->travel);
|
||||
$changed = false;
|
||||
|
||||
foreach ($bookingDto->getParticipants() as $index => $participant) {
|
||||
$currentInsurance = $participant->insurance;
|
||||
if (null === $currentInsurance || $currentInsurance->isNoInsurance()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$travelPrice = $this->priceCalculatorService->resolveInsuranceTravelPrice($bookingDto, $index, $currentInsurance);
|
||||
$eligibleInsurances = $this->insuranceService->getEligibleInsurances($selectableInsurances, $participant, $bookingDto, $travelPrice);
|
||||
|
||||
if ($this->isInsuranceInList($currentInsurance, $eligibleInsurances)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$reassignedInsurance = $this->insuranceService->reassignInsuranceForPriceChange(
|
||||
$selectableInsurances,
|
||||
$currentInsurance,
|
||||
$participant,
|
||||
$bookingDto,
|
||||
$travelPrice
|
||||
);
|
||||
|
||||
if (null !== $reassignedInsurance) {
|
||||
$participant->addNotification(
|
||||
'warning',
|
||||
sprintf('Versicherung vor der Übermittlung automatisch angepasst: %s', $reassignedInsurance->label)
|
||||
);
|
||||
} else {
|
||||
$participant->addNotification(
|
||||
'warning',
|
||||
'Die gewählte Versicherung ist für diese Buchung nicht mehr verfügbar und wurde entfernt. Bitte erneut auswählen.'
|
||||
);
|
||||
}
|
||||
|
||||
$participant->insurance = $reassignedInsurance;
|
||||
$changed = true;
|
||||
}
|
||||
|
||||
return $changed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a specific insurance exists in a list of insurances (by id).
|
||||
*
|
||||
* @param array<Insurance> $insuranceList
|
||||
*/
|
||||
private function isInsuranceInList(Insurance $targetInsurance, array $insuranceList): bool
|
||||
{
|
||||
foreach ($insuranceList as $insurance) {
|
||||
if ($insurance->id === $targetInsurance->id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the applicant's insurance to other participants if their selection requires it.
|
||||
*
|
||||
|
||||
@@ -19,6 +19,7 @@ use App\Service\BookingCreateContextFactory;
|
||||
use App\Service\BookingPriceCalculator;
|
||||
use App\Service\BookingPriceMismatchAnalyzer;
|
||||
use App\Service\BookingSessionManager;
|
||||
use App\Service\ParticipantFormSupport;
|
||||
use App\Service\RoomPricingCalculator;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@@ -40,6 +41,7 @@ class Step3Controller extends AbstractBookingCreateController
|
||||
private readonly BookingPriceCalculator $priceCalculator,
|
||||
private readonly BookingPriceMismatchAnalyzer $priceMismatchDiagnostics,
|
||||
private readonly ApiClient $apiClient,
|
||||
private readonly ParticipantFormSupport $participantFormSupportService,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
@@ -76,6 +78,12 @@ class Step3Controller extends AbstractBookingCreateController
|
||||
// Validate booking data with API by submitting an inquiry booking
|
||||
$inquiryResponse = $this->apiClient->createBookingInquiry($bookingCreateDto);
|
||||
|
||||
// Surface any insurance corrections made during payload building (e.g. a
|
||||
// stale price tier reassigned/cleared right before submission)
|
||||
foreach ($this->participantFormSupportService->collectAndClearNotifications($bookingCreateDto) as $notification) {
|
||||
$this->addFlash($notification['type'], $notification['message']);
|
||||
}
|
||||
|
||||
if ($inquiryResponse instanceof Notification) {
|
||||
$this->handleApiError(
|
||||
$this->logger,
|
||||
|
||||
@@ -20,6 +20,7 @@ use App\Service\BookingConfigurator;
|
||||
use App\Service\BookingCreateContextFactory;
|
||||
use App\Service\BookingSessionManager;
|
||||
use App\Service\NewsletterManager;
|
||||
use App\Service\ParticipantFormSupport;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -41,6 +42,7 @@ class Step4Controller extends AbstractBookingCreateController
|
||||
private readonly ApiClient $apiClient,
|
||||
private readonly CacheInterface $cache,
|
||||
private readonly NewsletterManager $doubleOptInService,
|
||||
private readonly ParticipantFormSupport $participantFormSupportService,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
@@ -78,6 +80,12 @@ class Step4Controller extends AbstractBookingCreateController
|
||||
// Submit final booking (already validated in Step 3)
|
||||
$bookingResponse = $this->apiClient->createBooking($bookingCreateDto);
|
||||
|
||||
// Surface any insurance corrections made during payload building (e.g. a
|
||||
// stale price tier reassigned/cleared right before submission)
|
||||
foreach ($this->participantFormSupportService->collectAndClearNotifications($bookingCreateDto) as $notification) {
|
||||
$this->addFlash($notification['type'], $notification['message']);
|
||||
}
|
||||
|
||||
if ($bookingResponse instanceof Notification) {
|
||||
$this->handleApiError(
|
||||
$this->logger,
|
||||
|
||||
@@ -67,9 +67,9 @@ class ParticipantEditDto
|
||||
* Validates that insurance is selected when required.
|
||||
*
|
||||
* Insurance is required for all participants in create mode, EXCEPT for dependent
|
||||
* participants when the applicant has enabled bulk insurance booking. In that case,
|
||||
* the insurance field is hidden and will be automatically assigned by the bulk
|
||||
* insurance handler.
|
||||
* participants when the applicant has enabled bulk insurance booking, or when the
|
||||
* applicant has a family insurance selected. In both cases, the insurance field is
|
||||
* hidden and coverage is derived from the applicant instead.
|
||||
*
|
||||
* In edit submissions, this validation is skipped entirely because insurance
|
||||
* data is readonly and preserved as-is from the BPN API.
|
||||
@@ -90,6 +90,10 @@ class ParticipantEditDto
|
||||
if (true === $applicant?->bulkInsuranceBooking) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (null !== $applicant?->insurance && true === $applicant->insurance->familyInsurance) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $this->participant->insurance) {
|
||||
|
||||
@@ -202,8 +202,6 @@ class BpnXmlAnonymizer
|
||||
$title = '';
|
||||
$gender = 'D';
|
||||
$nationality = 'XX';
|
||||
$birthDate = '01.01.1980';
|
||||
|
||||
$street = sprintf('%s %s', $this->faker->streetName(), $this->faker->buildingNumber());
|
||||
$postalCode = $this->faker->postcode();
|
||||
$city = $this->faker->city();
|
||||
@@ -232,7 +230,6 @@ class BpnXmlAnonymizer
|
||||
'title' => $title,
|
||||
'gender' => $gender,
|
||||
'nationality' => $nationality,
|
||||
'birthDate' => $birthDate,
|
||||
'street' => $street,
|
||||
'postalCode' => $postalCode,
|
||||
'city' => $city,
|
||||
@@ -389,11 +386,6 @@ class BpnXmlAnonymizer
|
||||
$this->replaceNodeValue($nationalityNode, $identity['nationality']);
|
||||
}
|
||||
|
||||
$birthDateNode = $this->getDirectChild($personNode, 'geburtsdatum');
|
||||
if (null !== $birthDateNode) {
|
||||
$this->replaceNodeValue($birthDateNode, $identity['birthDate']);
|
||||
}
|
||||
|
||||
$heightNode = $this->getDirectChild($personNode, 'sonstiges1');
|
||||
if (null !== $heightNode) {
|
||||
$this->replaceNodeValue($heightNode, $identity['height']);
|
||||
|
||||
@@ -28,3 +28,13 @@
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
{% endif %}
|
||||
{% if app.session.flashBag.peek('warning')|length > 0 %}
|
||||
{% embed '_partials/_modal.html.twig' with { 'level': 'warning', 'modal': true } %}
|
||||
{% block title %}
|
||||
Hinweis
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
{% include '_partials/_alert.html.twig' with { level: 'warning', messages: app.flashes('warning') } %}
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
{% endif %}
|
||||
@@ -1,9 +1,9 @@
|
||||
<div class="fixed inset-0 w-full h-full z-50" {{ stimulus_controller('modal') }} {{ stimulus_action('modal', 'close', 'modal-close@window') }}>
|
||||
<div class="absolute inset-0 backdrop-blur-sm" {{ stimulus_action('modal', 'close', 'click') }}></div>
|
||||
<div class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 px-4 w-full max-w-3xl">
|
||||
<div class="{{ html_classes('relative py-4 rounded-md', { 'bg-red-500': level == 'error', 'bg-green-500': level == 'success', 'bg-primary-light': level == 'info' }) }}">
|
||||
<div class="{{ html_classes('relative py-4 rounded-md', { 'bg-red-500': level == 'error', 'bg-green-500': level == 'success', 'bg-yellow-500': level == 'warning', 'bg-primary-light': level == 'info' }) }}">
|
||||
<div class="flex justify-between pb-4 px-4">
|
||||
<div class="text-2xl font-medium text-white">
|
||||
<div class="{{ html_classes('text-2xl font-medium', { 'text-gray-800': level == 'warning', 'text-white': level != 'warning' }) }}">
|
||||
{% block title %}{% endblock %}
|
||||
</div>
|
||||
<button type="button"
|
||||
|
||||
@@ -850,7 +850,13 @@ class BookingDataProcessorTest extends TestCase
|
||||
$bookingDto->participants = [$applicant, $dependent];
|
||||
|
||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
||||
$insuranceService->method('getSelectableInsurances')->willReturn([]);
|
||||
// Both insurances must already look eligible, otherwise the submit-time
|
||||
// reconciliation step (added for stale-insurance re-validation) would clear
|
||||
// them before propagation even runs - this test is only about propagation.
|
||||
$insuranceService->method('getSelectableInsurances')->willReturn([$familyInsurance, $dependentInsurance]);
|
||||
$insuranceService->method('getEligibleInsurances')->willReturnCallback(
|
||||
fn (array $insurances) => $insurances
|
||||
);
|
||||
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([
|
||||
0 => $familyInsurance,
|
||||
1 => null,
|
||||
@@ -858,6 +864,7 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(0.0);
|
||||
|
||||
$payloadBuilder = $this->createMock(BookingPayloadBuilder::class);
|
||||
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
||||
@@ -925,4 +932,148 @@ class BookingDataProcessorTest extends TestCase
|
||||
$this->assertSame($familyInsurance, $formData->participants[0]->insurance);
|
||||
$this->assertNull($formData->participants[1]->insurance, 'Dependent must lose their pre-existing individual insurance in edit mode once the applicant selects family insurance');
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: an insurance selected earlier can go stale by submission time (e.g. its
|
||||
* price tier no longer matches the current total, because the user added services on an
|
||||
* earlier step after choosing insurance and jumped straight to submission without
|
||||
* revisiting the insurance field). createBookingRequestPayload() must re-validate and
|
||||
* reassign to the correct tier right before the payload is built, so a stale ID never
|
||||
* reaches the BPN API.
|
||||
*/
|
||||
public function testCreateBookingRequestPayloadReassignsStaleInsuranceToCurrentPriceTier(): void
|
||||
{
|
||||
$staleInsurance = new Insurance();
|
||||
$staleInsurance->id = 'tier-low';
|
||||
$staleInsurance->familyInsurance = false;
|
||||
|
||||
$correctTierInsurance = new Insurance();
|
||||
$correctTierInsurance->id = 'tier-high';
|
||||
$correctTierInsurance->familyInsurance = false;
|
||||
|
||||
$applicant = $this->createMockParticipantDto(0, 'F');
|
||||
$applicant->insurance = $staleInsurance;
|
||||
|
||||
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
||||
$bookingDto->participants = [$applicant];
|
||||
|
||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
||||
$insuranceService->method('getSelectableInsurances')->willReturn([$staleInsurance, $correctTierInsurance]);
|
||||
// Only the higher tier is eligible at the current (updated) price.
|
||||
$insuranceService->method('getEligibleInsurances')->willReturn([$correctTierInsurance]);
|
||||
$insuranceService->method('reassignInsuranceForPriceChange')->willReturn($correctTierInsurance);
|
||||
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([0 => $correctTierInsurance]);
|
||||
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(2600.0);
|
||||
|
||||
$payloadBuilder = $this->createMock(BookingPayloadBuilder::class);
|
||||
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
||||
|
||||
$processor = new BookingDataProcessor(
|
||||
$insuranceService,
|
||||
$priceCalculatorService,
|
||||
new ServiceMappingCollector(),
|
||||
new ParticipantServiceProcessor(new NullLogger()),
|
||||
$payloadBuilder,
|
||||
new PersonalDataSynchronizer(),
|
||||
);
|
||||
|
||||
$processor->createBookingRequestPayload($bookingDto, 'ANFRAGE');
|
||||
|
||||
$this->assertSame($correctTierInsurance, $applicant->insurance);
|
||||
$this->assertCount(1, $applicant->notifications);
|
||||
$this->assertSame('warning', array_values($applicant->notifications)[0]['type']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: when a stale insurance has no eligible replacement at all (e.g. the total
|
||||
* price now falls outside every tier of that type), it must be cleared rather than
|
||||
* silently left in place and submitted anyway.
|
||||
*/
|
||||
public function testCreateBookingRequestPayloadClearsStaleInsuranceWithoutEligibleReplacement(): void
|
||||
{
|
||||
$staleInsurance = new Insurance();
|
||||
$staleInsurance->id = 'tier-low';
|
||||
$staleInsurance->familyInsurance = false;
|
||||
|
||||
$applicant = $this->createMockParticipantDto(0, 'F');
|
||||
$applicant->insurance = $staleInsurance;
|
||||
|
||||
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
||||
$bookingDto->participants = [$applicant];
|
||||
|
||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
||||
$insuranceService->method('getSelectableInsurances')->willReturn([$staleInsurance]);
|
||||
$insuranceService->method('getEligibleInsurances')->willReturn([]);
|
||||
$insuranceService->method('reassignInsuranceForPriceChange')->willReturn(null);
|
||||
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([0 => null]);
|
||||
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(9999.0);
|
||||
|
||||
$payloadBuilder = $this->createMock(BookingPayloadBuilder::class);
|
||||
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
||||
|
||||
$processor = new BookingDataProcessor(
|
||||
$insuranceService,
|
||||
$priceCalculatorService,
|
||||
new ServiceMappingCollector(),
|
||||
new ParticipantServiceProcessor(new NullLogger()),
|
||||
$payloadBuilder,
|
||||
new PersonalDataSynchronizer(),
|
||||
);
|
||||
|
||||
$processor->createBookingRequestPayload($bookingDto, 'ANFRAGE');
|
||||
|
||||
$this->assertNull($applicant->insurance);
|
||||
$this->assertCount(1, $applicant->notifications);
|
||||
$this->assertSame('warning', array_values($applicant->notifications)[0]['type']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: an insurance that's still eligible at submission time must be left
|
||||
* untouched - the reconciliation step must not fire (or notify) on the common,
|
||||
* unremarkable case where nothing has gone stale.
|
||||
*/
|
||||
public function testCreateBookingRequestPayloadLeavesStillEligibleInsuranceUntouched(): void
|
||||
{
|
||||
$insurance = new Insurance();
|
||||
$insurance->id = 'tier-1';
|
||||
$insurance->familyInsurance = false;
|
||||
|
||||
$applicant = $this->createMockParticipantDto(0, 'F');
|
||||
$applicant->insurance = $insurance;
|
||||
|
||||
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
||||
$bookingDto->participants = [$applicant];
|
||||
|
||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
||||
$insuranceService->method('getSelectableInsurances')->willReturn([$insurance]);
|
||||
$insuranceService->method('getEligibleInsurances')->willReturn([$insurance]);
|
||||
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([0 => $insurance]);
|
||||
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(500.0);
|
||||
|
||||
$payloadBuilder = $this->createMock(BookingPayloadBuilder::class);
|
||||
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
||||
|
||||
$processor = new BookingDataProcessor(
|
||||
$insuranceService,
|
||||
$priceCalculatorService,
|
||||
new ServiceMappingCollector(),
|
||||
new ParticipantServiceProcessor(new NullLogger()),
|
||||
$payloadBuilder,
|
||||
new PersonalDataSynchronizer(),
|
||||
);
|
||||
|
||||
$processor->createBookingRequestPayload($bookingDto, 'ANFRAGE');
|
||||
|
||||
$this->assertSame($insurance, $applicant->insurance);
|
||||
$this->assertCount(0, $applicant->notifications);
|
||||
}
|
||||
}
|
||||
@@ -728,6 +728,54 @@ class ParticipantEditDtoTest extends TestCase
|
||||
$this->assertCount(1, $insuranceViolations);
|
||||
}
|
||||
|
||||
public function testDependentWithoutInsurancePassesWhenApplicantHasFamilyInsurance(): void
|
||||
{
|
||||
$applicant = $this->createAdultParticipant('[email protected]');
|
||||
$applicant->insurance = $this->createMockInsurance(familyInsurance: true);
|
||||
|
||||
$dependent = $this->createAdultParticipant('[email protected]');
|
||||
$dependent->insurance = null;
|
||||
|
||||
$bookingDto = $this->createBookingDtoWithParticipants([$applicant, $dependent]);
|
||||
|
||||
$wrapper = new ParticipantEditDto(
|
||||
participant: $bookingDto->participants[1],
|
||||
bookingContext: $bookingDto,
|
||||
);
|
||||
|
||||
$violations = $this->validator->validate($wrapper, null, ['strict_required']);
|
||||
$insuranceViolations = array_filter(
|
||||
iterator_to_array($violations),
|
||||
fn ($v) => 'participant.insurance' === $v->getPropertyPath()
|
||||
);
|
||||
|
||||
$this->assertCount(0, $insuranceViolations);
|
||||
}
|
||||
|
||||
public function testDependentWithoutInsuranceFailsWhenApplicantHasNonFamilyInsurance(): void
|
||||
{
|
||||
$applicant = $this->createAdultParticipant('[email protected]');
|
||||
$applicant->insurance = $this->createMockInsurance(familyInsurance: false);
|
||||
|
||||
$dependent = $this->createAdultParticipant('[email protected]');
|
||||
$dependent->insurance = null;
|
||||
|
||||
$bookingDto = $this->createBookingDtoWithParticipants([$applicant, $dependent]);
|
||||
|
||||
$wrapper = new ParticipantEditDto(
|
||||
participant: $bookingDto->participants[1],
|
||||
bookingContext: $bookingDto,
|
||||
);
|
||||
|
||||
$violations = $this->validator->validate($wrapper, null, ['strict_required']);
|
||||
$insuranceViolations = array_filter(
|
||||
iterator_to_array($violations),
|
||||
fn ($v) => 'participant.insurance' === $v->getPropertyPath()
|
||||
);
|
||||
|
||||
$this->assertCount(1, $insuranceViolations);
|
||||
}
|
||||
|
||||
private function createBookingDtoWithParticipants(array $participants): BookingDto
|
||||
{
|
||||
$travel = new Travel();
|
||||
@@ -821,12 +869,13 @@ class ParticipantEditDtoTest extends TestCase
|
||||
return $service;
|
||||
}
|
||||
|
||||
private function createMockInsurance(): Insurance
|
||||
private function createMockInsurance(bool $familyInsurance = false): Insurance
|
||||
{
|
||||
$insurance = new Insurance();
|
||||
$insurance->id = '1';
|
||||
$insurance->label = 'Test Insurance';
|
||||
$insurance->price = 10.0;
|
||||
$insurance->familyInsurance = $familyInsurance;
|
||||
|
||||
return $insurance;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ class BpnXmlAnonymizerTest extends TestCase
|
||||
<anmelder>
|
||||
<name>Example</name>
|
||||
<vorname>Ava</vorname>
|
||||
<geburtsdatum>03.04.1991</geburtsdatum>
|
||||
<anschrift>
|
||||
<strasse>Testallee 7</strasse>
|
||||
<plz>10115</plz>
|
||||
@@ -32,6 +33,7 @@ class BpnXmlAnonymizerTest extends TestCase
|
||||
<teilnehmer id="1">
|
||||
<name>Example</name>
|
||||
<vorname>Ava</vorname>
|
||||
<geburtsdatum>03.04.1991</geburtsdatum>
|
||||
<anschrift>
|
||||
<strasse>Testallee 7</strasse>
|
||||
<plz>10115</plz>
|
||||
@@ -46,6 +48,7 @@ class BpnXmlAnonymizerTest extends TestCase
|
||||
<teilnehmer id="2">
|
||||
<name>Second</name>
|
||||
<vorname>Ben</vorname>
|
||||
<geburtsdatum>12.11.1987</geburtsdatum>
|
||||
<kommunikation>
|
||||
<email>[email protected]</email>
|
||||
</kommunikation>
|
||||
@@ -69,6 +72,9 @@ XML;
|
||||
$applicantMobilePhone = trim((string) $xpath->evaluate('string(//anmelder/kommunikation/telefonmobil)'));
|
||||
$participantOneMobilePhone = trim((string) $xpath->evaluate('string(//teilnehmer[1]/kommunikation/telefonmobil)'));
|
||||
$participantTwoName = trim((string) $xpath->evaluate('string(//teilnehmer[2]/name)'));
|
||||
$applicantBirthDate = trim((string) $xpath->evaluate('string(//anmelder/geburtsdatum)'));
|
||||
$participantOneBirthDate = trim((string) $xpath->evaluate('string(//teilnehmer[1]/geburtsdatum)'));
|
||||
$participantTwoBirthDate = trim((string) $xpath->evaluate('string(//teilnehmer[2]/geburtsdatum)'));
|
||||
|
||||
$this->assertNotSame('Example', $applicantName);
|
||||
$this->assertSame($applicantName, $participantOneName);
|
||||
@@ -76,6 +82,9 @@ XML;
|
||||
$this->assertSame('01000000002', $participantOneMobilePhone);
|
||||
$this->assertSame($applicantMobilePhone, $participantOneMobilePhone);
|
||||
$this->assertNotSame($participantOneName, $participantTwoName);
|
||||
$this->assertSame('03.04.1991', $applicantBirthDate);
|
||||
$this->assertSame('03.04.1991', $participantOneBirthDate);
|
||||
$this->assertSame('12.11.1987', $participantTwoBirthDate);
|
||||
$this->assertSame(3, $anonymizer->getLastIdentityCount());
|
||||
}
|
||||
|
||||
@@ -181,7 +190,7 @@ XML;
|
||||
$this->assertSame('Divers', $responseSalutation);
|
||||
$this->assertSame('', $responseTitle);
|
||||
$this->assertSame('D', $responseGender);
|
||||
$this->assertSame('01.01.1980', $responseBirthDate);
|
||||
$this->assertSame('16.04.1972', $responseBirthDate);
|
||||
$this->assertSame('XX', $responseNationality);
|
||||
$this->assertNotSame('Beispielweg 57', $responseStreet);
|
||||
$this->assertNotSame('42853', $responsePostalCode);
|
||||
@@ -501,7 +510,7 @@ XML;
|
||||
$this->assertSame('Divers', $salutation);
|
||||
$this->assertSame('', $title);
|
||||
$this->assertSame('D', $gender);
|
||||
$this->assertSame('01.01.1980', $birthDate);
|
||||
$this->assertSame('01.02.1990', $birthDate);
|
||||
$this->assertSame('XX', $nationality);
|
||||
$this->assertNotSame('Beispielweg 12', $street);
|
||||
$this->assertNotSame('12345', $postalCode);
|
||||
|
||||
Reference in new issue
Block a user