Apply fixes from StyleCI

This commit is contained in:
Nabeel Shahzad
2018-08-26 16:40:04 +00:00
committed by StyleCI Bot
parent 20f46adbc4
commit 9596d88b48
407 changed files with 4032 additions and 3286 deletions

View File

@@ -5,7 +5,8 @@ use App\Services\UserService;
class UserTest extends TestCase
{
protected $settingsRepo, $userSvc;
protected $settingsRepo;
protected $userSvc;
public function setUp()
{
@@ -20,8 +21,8 @@ class UserTest extends TestCase
*/
public function testRankSubfleets()
{
# Add subfleets and aircraft, but also add another
# set of subfleets
// Add subfleets and aircraft, but also add another
// set of subfleets
$subfleetA = $this->createSubfleetWithAircraft();
$this->createSubfleetWithAircraft();
@@ -46,38 +47,37 @@ class UserTest extends TestCase
$resp = $this->get('/api/user/fleet', [], $user)->assertStatus(200);
$body = $resp->json()['data'];
# Get the subfleet that's been added in
// Get the subfleet that's been added in
$subfleet_from_api = $body[0];
$this->assertEquals($subfleet->id, $subfleet_from_api['id']);
# Get all the aircraft from that subfleet
// Get all the aircraft from that subfleet
$aircraft_from_api = collect($subfleet_from_api['aircraft'])->pluck('id');
$this->assertEquals($added_aircraft, $aircraft_from_api);
/**
* Check the user ID call
*/
$resp = $this->get('/api/users/' . $user->id . '/fleet', [], $user)->assertStatus(200);
$resp = $this->get('/api/users/'.$user->id.'/fleet', [], $user)->assertStatus(200);
$body = $resp->json()['data'];
# Get the subfleet that's been added in
// Get the subfleet that's been added in
$subfleet_from_api = $body[0];
$this->assertEquals($subfleet->id, $subfleet_from_api['id']);
# Get all the aircraft from that subfleet
// Get all the aircraft from that subfleet
$aircraft_from_api = collect($subfleet_from_api['aircraft'])->pluck('id');
$this->assertEquals($added_aircraft, $aircraft_from_api);
}
/**
* Flip the setting for getting all of the user's aircraft restricted
* by rank. Make sure that they're all returned
*/
public function testGetAllAircraft()
{
# Add subfleets and aircraft, but also add another
# set of subfleets
// Add subfleets and aircraft, but also add another
// set of subfleets
$subfleetA = $this->createSubfleetWithAircraft();
$subfleetB = $this->createSubfleetWithAircraft();
@@ -104,13 +104,12 @@ class UserTest extends TestCase
$this->assertEquals($added_aircraft, $all_aircraft);
/**
* Check via API
*/
$resp = $this->get('/api/user/fleet', [], $user)->assertStatus(200);
# Get all the aircraft from that subfleet
// Get all the aircraft from that subfleet
$body = $resp->json()['data'];
$aircraft_from_api = array_merge(
collect($body[0]['aircraft'])->pluck('id')->toArray(),
@@ -128,8 +127,8 @@ class UserTest extends TestCase
*/
public function testGetAircraftAllowedFromFlight()
{
# Add subfleets and aircraft, but also add another
# set of subfleets
// Add subfleets and aircraft, but also add another
// set of subfleets
$airport = factory(App\Models\Airport::class)->create();
$subfleetA = $this->createSubfleetWithAircraft(2, $airport->id);
$subfleetB = $this->createSubfleetWithAircraft(2);
@@ -137,17 +136,17 @@ class UserTest extends TestCase
$rank = $this->createRank(10, [$subfleetA['subfleet']->id]);
$user = factory(App\Models\User::class)->create([
'curr_airport_id' => $airport->id,
'rank_id' => $rank->id,
'rank_id' => $rank->id,
]);
$flight = factory(App\Models\Flight::class)->create([
'airline_id' => $user->airline_id,
'airline_id' => $user->airline_id,
'dpt_airport_id' => $airport->id,
]);
$flight->subfleets()->syncWithoutDetaching([
$subfleetA['subfleet']->id,
$subfleetB['subfleet']->id
$subfleetB['subfleet']->id,
]);
/*
@@ -158,13 +157,13 @@ class UserTest extends TestCase
* Do some sanity checks first
*/
# Make sure no flights are filtered out
// Make sure no flights are filtered out
$this->settingsRepo->store('pilots.only_flights_from_current', false);
# And restrict the aircraft
// And restrict the aircraft
$this->settingsRepo->store('pireps.restrict_aircraft_to_rank', false);
$response = $this->get('/api/flights/' . $flight->id, [], $user);
$response = $this->get('/api/flights/'.$flight->id, [], $user);
$response->assertStatus(200);
$this->assertCount(2, $response->json()['data']['subfleets']);
@@ -176,7 +175,7 @@ class UserTest extends TestCase
/**
* Make sure it's filtered out from the single flight call
*/
$response = $this->get('/api/flights/' . $flight->id, [], $user);
$response = $this->get('/api/flights/'.$flight->id, [], $user);
$response->assertStatus(200);
$this->assertCount(1, $response->json()['data']['subfleets']);
@@ -191,7 +190,7 @@ class UserTest extends TestCase
/**
* Filtered from search?
*/
$response = $this->get('/api/flights/search?flight_id=' . $flight->id, [], $user);
$response = $this->get('/api/flights/search?flight_id='.$flight->id, [], $user);
$response->assertStatus(200);
$body = $response->json()['data'];
$this->assertCount(1, $body[0]['subfleets']);