fix: ensure pickups node exists in api payload
This commit is contained in:
@@ -203,6 +203,8 @@ class BookingPayloadBuilder
|
|||||||
*/
|
*/
|
||||||
public function buildPickupPayload(array &$payload, Booking $bookingData): void
|
public function buildPickupPayload(array &$payload, Booking $bookingData): void
|
||||||
{
|
{
|
||||||
|
$payload['zustiege'] = [];
|
||||||
|
|
||||||
if (0 < count($bookingData->pickups)) {
|
if (0 < count($bookingData->pickups)) {
|
||||||
$payload['zustiege']['zustieg'] = [];
|
$payload['zustiege']['zustieg'] = [];
|
||||||
foreach ($bookingData->pickups as $pickup) {
|
foreach ($bookingData->pickups as $pickup) {
|
||||||
@@ -390,6 +392,9 @@ class BookingPayloadBuilder
|
|||||||
$this->addRoomMappingsToPayload($payload, $roomMap, $bookingDto);
|
$this->addRoomMappingsToPayload($payload, $roomMap, $bookingDto);
|
||||||
$this->addServicesFromMap($payload, 'zusatzleistungen', 'zusatzleistung', '@idleistung', $serviceMap);
|
$this->addServicesFromMap($payload, 'zusatzleistungen', 'zusatzleistung', '@idleistung', $serviceMap);
|
||||||
$this->addServicesFromMap($payload, 'zustiege', 'zustieg', '@idzustieg', $pickupMap);
|
$this->addServicesFromMap($payload, 'zustiege', 'zustieg', '@idzustieg', $pickupMap);
|
||||||
|
if (false === array_key_exists('zustiege', $payload)) {
|
||||||
|
$payload['zustiege'] = [];
|
||||||
|
}
|
||||||
|
|
||||||
$dropOffMap = $this->mappingCollector->collectDropOffMappings($bookingDto);
|
$dropOffMap = $this->mappingCollector->collectDropOffMappings($bookingDto);
|
||||||
$this->addServicesFromMap($payload, 'ausstiege', 'ausstieg', '@idzustieg', $dropOffMap);
|
$this->addServicesFromMap($payload, 'ausstiege', 'ausstieg', '@idzustieg', $dropOffMap);
|
||||||
|
|||||||
@@ -138,7 +138,8 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
|
|
||||||
$result = $this->processor->createUpdateRequestPayload($formData);
|
$result = $this->processor->createUpdateRequestPayload($formData);
|
||||||
|
|
||||||
$this->assertArrayNotHasKey('zustiege', $result);
|
$this->assertArrayHasKey('zustiege', $result);
|
||||||
|
$this->assertSame([], $result['zustiege']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUnusedServicesAreRemoved(): void
|
public function testUnusedServicesAreRemoved(): void
|
||||||
@@ -241,7 +242,8 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
|
|
||||||
$result = $this->processor->createUpdateRequestPayload($formData);
|
$result = $this->processor->createUpdateRequestPayload($formData);
|
||||||
|
|
||||||
$this->assertArrayNotHasKey('zustiege', $result);
|
$this->assertArrayHasKey('zustiege', $result);
|
||||||
|
$this->assertSame([], $result['zustiege']);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createCompleteFormData(): BookingDto
|
private function createCompleteFormData(): BookingDto
|
||||||
|
|||||||
Reference in New Issue
Block a user