This commit is contained in:
@@ -33,3 +33,20 @@ test('does not crash if the booking was soft-deleted before this queued listener
|
||||
expect(fn () => (new MarkBookingPaid)->handle(new PaymentCompleted($payment->fresh())))
|
||||
->not->toThrow(Throwable::class);
|
||||
});
|
||||
|
||||
test('a round trip: paying the primary leg also confirms its linked return leg', function () {
|
||||
$outbound = Booking::factory()->create(['status' => BookingStatus::PendingPayment]);
|
||||
$return = Booking::factory()->create([
|
||||
'status' => BookingStatus::PendingPayment,
|
||||
'is_return_leg' => true,
|
||||
'linked_booking_id' => $outbound->id,
|
||||
]);
|
||||
$outbound->update(['linked_booking_id' => $return->id]);
|
||||
|
||||
$payment = Payment::factory()->completed()->create(['booking_id' => $outbound->id]);
|
||||
|
||||
(new MarkBookingPaid)->handle(new PaymentCompleted($payment));
|
||||
|
||||
expect($outbound->refresh()->status)->toBe(BookingStatus::Confirmed)
|
||||
->and($return->refresh()->status)->toBe(BookingStatus::Confirmed);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user