create(['status' => BookingStatus::PendingPayment]); $payment = Payment::factory()->completed()->create(['booking_id' => $booking->id]); (new MarkBookingPaid)->handle(new PaymentCompleted($payment)); expect($booking->refresh()->status)->toBe(BookingStatus::Confirmed); }); test('does not touch a booking that already moved on for another reason', function () { $booking = Booking::factory()->create(['status' => BookingStatus::Cancelled]); $payment = Payment::factory()->completed()->create(['booking_id' => $booking->id, 'status' => PaymentStatus::Completed]); (new MarkBookingPaid)->handle(new PaymentCompleted($payment)); expect($booking->refresh()->status)->toBe(BookingStatus::Cancelled); });