fix: ensure pickups node exists in api payload

This commit is contained in:
Björn Fromme
2026-03-16 12:03:00 +01:00
parent 709b0ff61e
commit 1cc7a025a1
2 changed files with 9 additions and 2 deletions
@@ -203,6 +203,8 @@ class BookingPayloadBuilder
*/
public function buildPickupPayload(array &$payload, Booking $bookingData): void
{
$payload['zustiege'] = [];
if (0 < count($bookingData->pickups)) {
$payload['zustiege']['zustieg'] = [];
foreach ($bookingData->pickups as $pickup) {
@@ -390,6 +392,9 @@ class BookingPayloadBuilder
$this->addRoomMappingsToPayload($payload, $roomMap, $bookingDto);
$this->addServicesFromMap($payload, 'zusatzleistungen', 'zusatzleistung', '@idleistung', $serviceMap);
$this->addServicesFromMap($payload, 'zustiege', 'zustieg', '@idzustieg', $pickupMap);
if (false === array_key_exists('zustiege', $payload)) {
$payload['zustiege'] = [];
}
$dropOffMap = $this->mappingCollector->collectDropOffMappings($bookingDto);
$this->addServicesFromMap($payload, 'ausstiege', 'ausstieg', '@idzustieg', $dropOffMap);
@@ -138,7 +138,8 @@ class BookingDataProcessorTest extends TestCase
$result = $this->processor->createUpdateRequestPayload($formData);
$this->assertArrayNotHasKey('zustiege', $result);
$this->assertArrayHasKey('zustiege', $result);
$this->assertSame([], $result['zustiege']);
}
public function testUnusedServicesAreRemoved(): void
@@ -241,7 +242,8 @@ class BookingDataProcessorTest extends TestCase
$result = $this->processor->createUpdateRequestPayload($formData);
$this->assertArrayNotHasKey('zustiege', $result);
$this->assertArrayHasKey('zustiege', $result);
$this->assertSame([], $result['zustiege']);
}
private function createCompleteFormData(): BookingDto