This commit is contained in:
@@ -25,14 +25,26 @@ test('an ev route belongs to a company and two destinations', function () {
|
||||
->and($route->toDestination->is($to))->toBeTrue();
|
||||
});
|
||||
|
||||
test('is_round_trip and is_active cast to boolean', function () {
|
||||
test('is_active casts to boolean', function () {
|
||||
$route = EvRoute::factory()->create([
|
||||
'is_round_trip' => 1,
|
||||
'is_active' => 0,
|
||||
]);
|
||||
|
||||
expect($route->is_round_trip)->toBeTrue()
|
||||
->and($route->is_active)->toBeFalse();
|
||||
expect($route->is_active)->toBeFalse();
|
||||
});
|
||||
|
||||
test('isReverseOf detects a route with from/to swapped', function () {
|
||||
$a = Destination::factory()->create();
|
||||
$b = Destination::factory()->create();
|
||||
|
||||
$outbound = EvRoute::factory()->create(['from_destination_id' => $a->id, 'to_destination_id' => $b->id]);
|
||||
$return = EvRoute::factory()->create(['from_destination_id' => $b->id, 'to_destination_id' => $a->id]);
|
||||
$unrelated = EvRoute::factory()->create();
|
||||
|
||||
expect($return->isReverseOf($outbound))->toBeTrue()
|
||||
->and($outbound->isReverseOf($return))->toBeTrue()
|
||||
->and($unrelated->isReverseOf($outbound))->toBeFalse()
|
||||
->and($outbound->isReverseOf($outbound))->toBeFalse();
|
||||
});
|
||||
|
||||
test('a route can be attached to time slots via the pivot, carrying its own is_active flag', function () {
|
||||
|
||||
Reference in New Issue
Block a user