Refuse pirep prefile is user not allowed to use aircraft #170
This commit is contained in:
@@ -5,15 +5,34 @@
|
||||
|
||||
namespace Tests;
|
||||
|
||||
class TestData
|
||||
trait TestData
|
||||
{
|
||||
/**
|
||||
* Create a new PIREP with a proper subfleet/rank/user and an
|
||||
* aircraft that the user is allowed to fly
|
||||
* @return \App\Models\Pirep
|
||||
*/
|
||||
protected function createPirep()
|
||||
{
|
||||
$subfleet = $this->createSubfleetWithAircraft(2);
|
||||
$rank = $this->createRank(10, [$subfleet['subfleet']->id]);
|
||||
$this->user = factory(\App\Models\User::class)->create([
|
||||
'rank_id' => $rank->id
|
||||
]);
|
||||
|
||||
// Return a Pirep model
|
||||
return factory(\App\Models\Pirep::class)->make([
|
||||
'aircraft_id' => $subfleet['aircraft']->random()->id
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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=[])
|
||||
public function createRank($hours=0, array $subfleet_ids)
|
||||
{
|
||||
$attrs = [];
|
||||
|
||||
@@ -32,9 +51,10 @@ class TestData
|
||||
/**
|
||||
* Create a subfleet with a number of aircraft assigned
|
||||
* @param null $aircraft_count
|
||||
* @param null $airport_id
|
||||
* @return mixed
|
||||
*/
|
||||
public static function createSubfleetWithAircraft($aircraft_count = null, $airport_id=null)
|
||||
public function createSubfleetWithAircraft($aircraft_count = null, $airport_id=null)
|
||||
{
|
||||
$subfleet = factory(\App\Models\Subfleet::class)->create();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user