add notes/remark and refactor round-trip
PHP Tests / php-tests (push) Has been cancelled

This commit is contained in:
Nyan Lin Paing
2026-08-22 21:43:41 +07:00
parent 894352b43f
commit fa908cdcaf
46 changed files with 1679 additions and 182 deletions
@@ -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 () {