Add calls and API to get user's fleet, determined by rank #35

This commit is contained in:
Nabeel Shahzad
2018-01-10 18:40:01 -06:00
parent 8aacd844b3
commit bf4e164e0d
6 changed files with 164 additions and 5 deletions

54
tests/TestData.php Normal file
View File

@@ -0,0 +1,54 @@
<?php
/**
*
*/
namespace Tests;
class TestData
{
/**
* Create a rank and associate the given subfleet IDs with it
* @param int $hours
* @param array $subfleet_ids
* @return mixed
*/
public static function createRank($hours=0, $subfleet_ids=[])
{
$attrs = [];
if($hours === null) {
$attrs['hours'] = $hours;
}
$rank = factory(\App\Models\Rank::class)->create($attrs);
if(!empty($subfleet_ids)) {
$rank->subfleets()->syncWithoutDetaching($subfleet_ids);
}
return $rank;
}
/**
* Create a subfleet with a number of aircraft assigned
* @param null $aircraft_count
* @return mixed
*/
public static function createSubfleetWithAircraft($aircraft_count = null)
{
$subfleet = factory(\App\Models\Subfleet::class)->create();
if($aircraft_count === null) {
$aircraft_count = \random_int(2, 10);
}
$aircraft = factory(\App\Models\Aircraft::class, $aircraft_count)->create([
'subfleet_id' => $subfleet->id
]);
return [
'subfleet' => $subfleet,
'aircraft' => $aircraft,
];
}
}