diff --git a/src/BusProNet/DataProcessor/BookingPayloadBuilder.php b/src/BusProNet/DataProcessor/BookingPayloadBuilder.php index 3af25f2..f3f9ade 100644 --- a/src/BusProNet/DataProcessor/BookingPayloadBuilder.php +++ b/src/BusProNet/DataProcessor/BookingPayloadBuilder.php @@ -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); diff --git a/tests/BusProNet/DataProcessor/BookingDataProcessorTest.php b/tests/BusProNet/DataProcessor/BookingDataProcessorTest.php index d6633d0..ff2b98b 100644 --- a/tests/BusProNet/DataProcessor/BookingDataProcessorTest.php +++ b/tests/BusProNet/DataProcessor/BookingDataProcessorTest.php @@ -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