Skip to content

Commit

Permalink
fix: cargo allocator crash when cargo flight but no airline
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyTWF committed Apr 22, 2024
1 parent 155d3db commit 0cb27ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ public function __construct(AirlineService $airlineService)

public function allocate(NetworkAircraft $aircraft): ?int
{
// If the aircraft doesnt have an airline, we cant allocate a stand
// If the aircraft isn't a cargo airline or a cargo flight, this rule doesn't apply
if (!$this->isCargoAirline($aircraft) && !$this->isCargoFlight($aircraft)) {
return null;
}

// If the aircarft has no airline at all, there's nothing we can do
if ($aircraft->airline_id === null) {
return null;
}

return $this->selectAirlineSpecificStands(
$aircraft,
$this->queryFilter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ public function testItDoesntAllocateCargoStandsIfNoAirline()
$this->assertNull($allocation);
}

public function testItDoesntAllocateCargoStandsIfNoAirlineButIsCargoFlight()
{
$aircraft = $this->createAircraft('ABCDEF', 'EGLL');
$aircraft->remarks = 'Some stuff RMK/CARGO Some more stuff';
$allocation = $this->allocator->allocate($aircraft);
$this->assertNull($allocation);
}

public function testItDoesntRankStandsIfUnknownAircraft()
{
$aircraft = $this->newAircraft('BAW1234', 'EGLL', 'C172');
Expand Down

0 comments on commit 0cb27ff

Please sign in to comment.