This commit is contained in:
@@ -74,3 +74,25 @@ test('reassigning a different driver on a still-confirmed booking overwrites the
|
||||
expect($booking->refresh()->driver_name)->toBe('Daw Hla')
|
||||
->and($booking->car_plate_number)->toBe('YGN-5678');
|
||||
});
|
||||
|
||||
test('a round trip: assigning a driver to the outbound leg does not touch the linked return leg', function () {
|
||||
$outbound = Booking::factory()->create(['status' => BookingStatus::Confirmed]);
|
||||
$return = Booking::factory()->create([
|
||||
'status' => BookingStatus::Confirmed,
|
||||
'is_return_leg' => true,
|
||||
'linked_booking_id' => $outbound->id,
|
||||
]);
|
||||
$outbound->update(['linked_booking_id' => $return->id]);
|
||||
|
||||
(new AssignDriverAction)->handle($outbound, new AssignDriverData(
|
||||
driverName: 'U Aung',
|
||||
driverPhone: '+959111222333',
|
||||
carPlateNumber: 'YGN-1234',
|
||||
));
|
||||
|
||||
// Each leg has its own independent driver/vehicle slot — the return leg
|
||||
// can get a completely different (or no-yet-assigned) vehicle, per the
|
||||
// "next available vehicle" business rule (domain.md §2b).
|
||||
expect($outbound->refresh()->driver_name)->toBe('U Aung')
|
||||
->and($return->refresh()->driver_name)->toBeNull();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user