diff --git a/app/Http/Controllers/SquawkController.php b/app/Http/Controllers/SquawkController.php index 804bbf051..69652a357 100644 --- a/app/Http/Controllers/SquawkController.php +++ b/app/Http/Controllers/SquawkController.php @@ -161,7 +161,7 @@ public function assignLocalSquawk(Request $request, string $callsign) : JsonResp $request, [ 'unit' => 'required|alpha', - 'rules' => 'required|in:V,I', + 'rules' => 'required|in:V,I,S', ] ); diff --git a/app/Services/SquawkService.php b/app/Services/SquawkService.php index 289c7caf6..14eef5eef 100644 --- a/app/Services/SquawkService.php +++ b/app/Services/SquawkService.php @@ -22,7 +22,7 @@ class SquawkService { /** - * Constant deemed to mean Any Flight Rules + * Constant deemed to mean Any Flight Rules. * * @var String */ @@ -103,6 +103,10 @@ public function assignLocalSquawk(string $callsign, string $unit, string $rules) throw new InvalidArgumentException('Unit not found'); } + if ($rules === 'S') { + $rules = 'V'; + } + $allRanges = $unit->ranges; $ruleSpecificRanges = $allRanges->where('rules', $rules)->shuffle(); $rangesToUse = ($ruleSpecificRanges->isNotEmpty()) diff --git a/tests/app/Services/SquawkServiceTest.php b/tests/app/Services/SquawkServiceTest.php index 6f72a44c8..79a47e3a0 100644 --- a/tests/app/Services/SquawkServiceTest.php +++ b/tests/app/Services/SquawkServiceTest.php @@ -207,6 +207,11 @@ public function testItAssignsFlightRuleSpecificLocalSquawks() $this->assertSame('3762', $this->squawkService->assignLocalSquawk('BAW9AZ', 'EGKA', 'I')->squawk()); } + public function testLocalSquawksTreatsSvfrAsVfr() + { + $this->assertSame('3763', $this->squawkService->assignLocalSquawk('BAW9AZ', 'EGKA', 'S')->squawk()); + } + public function testItAuditsWhoAssignsLocalSquawks() { $this->squawkService->assignLocalSquawk('BAW9AZ', 'EGKA', 'I');