Laravel 9 Update (#1413)
Update to Laravel 9 and PHP 8+ Co-authored-by: B.Fatih KOZ <fatih.koz@gmail.com>
This commit is contained in:
@@ -82,11 +82,11 @@ class AcarsTest extends TestCase
|
||||
*/
|
||||
public function testPrefileErrors()
|
||||
{
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->user = User::factory()->create();
|
||||
|
||||
$airport = factory(Airport::class)->create();
|
||||
$airline = factory(Airline::class)->create();
|
||||
$aircraft = factory(Aircraft::class)->create();
|
||||
$airport = Airport::factory()->create();
|
||||
$airline = Airline::factory()->create();
|
||||
$aircraft = Aircraft::factory()->create();
|
||||
|
||||
/**
|
||||
* INVALID AIRLINE_ID FIELD
|
||||
@@ -113,19 +113,19 @@ class AcarsTest extends TestCase
|
||||
$this->settingsRepo->store('pireps.restrict_aircraft_to_rank', false);
|
||||
$this->settingsRepo->store('pireps.only_aircraft_at_dpt_airport', true);
|
||||
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->user = User::factory()->create();
|
||||
|
||||
/** @var Airport $airport */
|
||||
$airport = factory(Airport::class)->create();
|
||||
$airport = Airport::factory()->create();
|
||||
|
||||
/** @var Airport $airport */
|
||||
$aircraft_airport = factory(Airport::class)->create();
|
||||
$aircraft_airport = Airport::factory()->create();
|
||||
|
||||
/** @var Airline $airline */
|
||||
$airline = factory(Airline::class)->create();
|
||||
$airline = Airline::factory()->create();
|
||||
|
||||
/** @var Aircraft $aircraft */
|
||||
$aircraft = factory(Aircraft::class)->create(['airport_id' => $aircraft_airport->id]);
|
||||
$aircraft = Aircraft::factory()->create(['airport_id' => $aircraft_airport->id]);
|
||||
|
||||
/**
|
||||
* INVALID AIRLINE_ID FIELD
|
||||
@@ -153,10 +153,10 @@ class AcarsTest extends TestCase
|
||||
|
||||
public function testBlankAirport()
|
||||
{
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->user = User::factory()->create();
|
||||
|
||||
$airline = factory(Airline::class)->create();
|
||||
$aircraft = factory(Aircraft::class)->create();
|
||||
$airline = Airline::factory()->create();
|
||||
$aircraft = Aircraft::factory()->create();
|
||||
|
||||
/**
|
||||
* INVALID AIRLINE_ID FIELD
|
||||
@@ -191,13 +191,13 @@ class AcarsTest extends TestCase
|
||||
$this->settingsRepo->store('pilots.only_flights_from_current', true);
|
||||
$this->settingsRepo->store('pireps.restrict_aircraft_to_rank', false);
|
||||
|
||||
$this->user = factory(User::class)->create([
|
||||
$this->user = User::factory()->create([
|
||||
'curr_airport_id' => 'KJFK',
|
||||
]);
|
||||
|
||||
$airport = factory(Airport::class)->create();
|
||||
$airline = factory(Airline::class)->create();
|
||||
$aircraft = factory(Aircraft::class)->create();
|
||||
$airport = Airport::factory()->create();
|
||||
$airline = Airline::factory()->create();
|
||||
$aircraft = Aircraft::factory()->create();
|
||||
|
||||
/**
|
||||
* INVALID AIRLINE_ID FIELD
|
||||
@@ -231,18 +231,18 @@ class AcarsTest extends TestCase
|
||||
$this->settingsRepo->store('pireps.restrict_aircraft_to_rank', false);
|
||||
|
||||
/** @var User user */
|
||||
$this->user = factory(User::class)->create([
|
||||
$this->user = User::factory()->create([
|
||||
'curr_airport_id' => 'KJFK',
|
||||
]);
|
||||
|
||||
/** @var Airport $airport */
|
||||
$airport = factory(Airport::class)->create();
|
||||
$airport = Airport::factory()->create();
|
||||
|
||||
/** @var Airline $airline */
|
||||
$airline = factory(Airline::class)->create();
|
||||
$airline = Airline::factory()->create();
|
||||
|
||||
/** @var Aircraft $aircraft */
|
||||
$aircraft = factory(Aircraft::class)->create([
|
||||
$aircraft = Aircraft::factory()->create([
|
||||
'airport_id' => 'KAUS',
|
||||
]);
|
||||
|
||||
@@ -275,16 +275,23 @@ class AcarsTest extends TestCase
|
||||
{
|
||||
$subfleet = $this->createSubfleetWithAircraft(2);
|
||||
$rank = $this->createRank(10, [$subfleet['subfleet']->id]);
|
||||
$fare = factory(Fare::class)->create();
|
||||
|
||||
$this->user = factory(User::class)->create(
|
||||
/** @var Fare $fare */
|
||||
$fare = Fare::factory()->create();
|
||||
|
||||
$this->user = User::factory()->create(
|
||||
[
|
||||
'rank_id' => $rank->id,
|
||||
]
|
||||
);
|
||||
|
||||
$airport = factory(Airport::class)->create();
|
||||
$airline = factory(Airline::class)->create();
|
||||
/** @var Airport $airport */
|
||||
$airport = Airport::factory()->create();
|
||||
|
||||
/** @var Airline $airline */
|
||||
$airline = Airline::factory()->create();
|
||||
|
||||
/** @var Aircraft $aircraft */
|
||||
$aircraft = $subfleet['aircraft']->random();
|
||||
|
||||
$uri = '/api/pireps/prefile';
|
||||
@@ -314,6 +321,14 @@ class AcarsTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
$pirep = $response->json('data');
|
||||
|
||||
$this->assertEquals(400, $pirep['planned_distance']['nmi']);
|
||||
$this->assertEquals(460.31, $pirep['planned_distance']['mi']);
|
||||
$this->assertEquals(740.8, $pirep['planned_distance']['km']);
|
||||
$this->assertEquals(740800, $pirep['planned_distance']['m']);
|
||||
|
||||
// Are date times in UTC?
|
||||
$this->assertTrue(str_ends_with($pirep['submitted_at'], 'Z'));
|
||||
|
||||
// See that the fields and fares were set
|
||||
$fares = PirepFare::where('pirep_id', $pirep['id'])->get();
|
||||
$this->assertCount(1, $fares);
|
||||
@@ -375,12 +390,12 @@ class AcarsTest extends TestCase
|
||||
$subfleet = $this->createSubfleetWithAircraft(2);
|
||||
$rank = $this->createRank(10, [$subfleet['subfleet']->id]);
|
||||
|
||||
$this->user = factory(User::class)->create([
|
||||
$this->user = User::factory()->create([
|
||||
'rank_id' => $rank->id,
|
||||
]);
|
||||
|
||||
$airport = factory(Airport::class)->create();
|
||||
$airline = factory(Airline::class)->create();
|
||||
$airport = Airport::factory()->create();
|
||||
$airline = Airline::factory()->create();
|
||||
$aircraft = $subfleet['aircraft']->random();
|
||||
|
||||
$uri = '/api/pireps/prefile';
|
||||
@@ -427,15 +442,15 @@ class AcarsTest extends TestCase
|
||||
$rank = $this->createRank(10, [$subfleet['subfleet']->id]);
|
||||
|
||||
/** @var User user */
|
||||
$this->user = factory(User::class)->create([
|
||||
$this->user = User::factory()->create([
|
||||
'rank_id' => $rank->id,
|
||||
]);
|
||||
|
||||
/** @var Airport $airport */
|
||||
$airport = factory(Airport::class)->create();
|
||||
$airport = Airport::factory()->create();
|
||||
|
||||
/** @var Airline $airline */
|
||||
$airline = factory(Airline::class)->create();
|
||||
$airline = Airline::factory()->create();
|
||||
|
||||
/** @var Aircraft $aircraft */
|
||||
$aircraft = $subfleet['aircraft']->random();
|
||||
@@ -510,8 +525,7 @@ class AcarsTest extends TestCase
|
||||
$response->assertStatus(400);
|
||||
|
||||
// Post an ACARS update
|
||||
$acars = factory(Acars::class)->make(['pirep_id' => $pirep_id])->toArray();
|
||||
|
||||
$acars = Acars::factory()->make(['pirep_id' => $pirep_id])->toArray();
|
||||
$acars = $this->transformData($acars);
|
||||
|
||||
$update = ['positions' => [$acars]];
|
||||
@@ -519,7 +533,8 @@ class AcarsTest extends TestCase
|
||||
$response->assertStatus(200)->assertJson(['count' => 1]);
|
||||
|
||||
// Read that if the ACARS record posted
|
||||
$acars_data = $this->get($uri)->json()['data'][0];
|
||||
$response = $this->get($uri);
|
||||
$acars_data = $response->json('data')[0];
|
||||
$this->assertEquals(round($acars['lat'], 2), round($acars_data['lat'], 2));
|
||||
$this->assertEquals(round($acars['lon'], 2), round($acars_data['lon'], 2));
|
||||
$this->assertEquals($acars['log'], $acars_data['log']);
|
||||
@@ -603,15 +618,15 @@ class AcarsTest extends TestCase
|
||||
$subfleet = $this->createSubfleetWithAircraft(2);
|
||||
$rank = $this->createRank(10, [$subfleet['subfleet']->id]);
|
||||
|
||||
$this->user = factory(User::class)->create([
|
||||
$this->user = User::factory()->create([
|
||||
'rank_id' => $rank->id,
|
||||
]);
|
||||
|
||||
/** @var Airport $airport */
|
||||
$airport = factory(Airport::class)->create();
|
||||
$airport = Airport::factory()->create();
|
||||
|
||||
/** @var Airline $airline */
|
||||
$airline = factory(Airline::class)->create();
|
||||
$airline = Airline::factory()->create();
|
||||
|
||||
/** @var Aircraft $aircraft */
|
||||
$aircraft = $subfleet['aircraft']->random();
|
||||
@@ -668,8 +683,8 @@ class AcarsTest extends TestCase
|
||||
{
|
||||
$this->settingsRepo->store('pireps.restrict_aircraft_to_rank', true);
|
||||
|
||||
$airport = factory(Airport::class)->create();
|
||||
$airline = factory(Airline::class)->create();
|
||||
$airport = Airport::factory()->create();
|
||||
$airline = Airline::factory()->create();
|
||||
|
||||
// Add subfleets and aircraft, but also add another set of subfleets
|
||||
$subfleetA = $this->createSubfleetWithAircraft(1);
|
||||
@@ -679,7 +694,7 @@ class AcarsTest extends TestCase
|
||||
|
||||
$rank = $this->createRank(10, [$subfleetA['subfleet']->id]);
|
||||
|
||||
$this->user = factory(User::class)->create(
|
||||
$this->user = User::factory()->create(
|
||||
[
|
||||
'rank_id' => $rank->id,
|
||||
]
|
||||
@@ -714,8 +729,8 @@ class AcarsTest extends TestCase
|
||||
{
|
||||
$this->settingsRepo->store('pireps.restrict_aircraft_to_rank', false);
|
||||
|
||||
$airport = factory(Airport::class)->create();
|
||||
$airline = factory(Airline::class)->create();
|
||||
$airport = Airport::factory()->create();
|
||||
$airline = Airline::factory()->create();
|
||||
|
||||
// Add subfleets and aircraft, but also add another set of subfleets
|
||||
$subfleetA = $this->createSubfleetWithAircraft(1);
|
||||
@@ -725,7 +740,7 @@ class AcarsTest extends TestCase
|
||||
|
||||
$rank = $this->createRank(10, [$subfleetA['subfleet']->id]);
|
||||
|
||||
$this->user = factory(User::class)->create(
|
||||
$this->user = User::factory()->create(
|
||||
[
|
||||
'rank_id' => $rank->id,
|
||||
]
|
||||
@@ -767,7 +782,7 @@ class AcarsTest extends TestCase
|
||||
|
||||
// Post an ACARS update
|
||||
$acars_count = random_int(5, 10);
|
||||
$acars = factory(Acars::class, $acars_count)->make(['id' => ''])
|
||||
$acars = Acars::factory()->count($acars_count)->make(['id' => ''])
|
||||
->map(function ($point) {
|
||||
$point['id'] = Utils::generateNewId();
|
||||
return $point;
|
||||
@@ -788,7 +803,7 @@ class AcarsTest extends TestCase
|
||||
|
||||
public function testNonExistentPirepGet()
|
||||
{
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->user = User::factory()->create();
|
||||
|
||||
$uri = '/api/pireps/DOESNTEXIST/acars';
|
||||
$response = $this->get($uri);
|
||||
@@ -797,10 +812,10 @@ class AcarsTest extends TestCase
|
||||
|
||||
public function testNonExistentPirepStore()
|
||||
{
|
||||
$this->user = factory(User::class)->create();
|
||||
$this->user = User::factory()->create();
|
||||
|
||||
$uri = '/api/pireps/DOESNTEXIST/acars/position';
|
||||
$acars = factory(Acars::class)->make()->toArray();
|
||||
$acars = Acars::factory()->make()->toArray();
|
||||
$response = $this->post($uri, $acars);
|
||||
$response->assertStatus(404);
|
||||
}
|
||||
@@ -815,7 +830,7 @@ class AcarsTest extends TestCase
|
||||
|
||||
$dt = date('c');
|
||||
$uri = '/api/pireps/'.$pirep_id.'/acars/position';
|
||||
$acars = factory(Acars::class)->make([
|
||||
$acars = Acars::factory()->make([
|
||||
'sim_time' => $dt,
|
||||
])->toArray();
|
||||
|
||||
@@ -864,7 +879,7 @@ class AcarsTest extends TestCase
|
||||
$response = $this->post($uri, $pirep);
|
||||
$pirep_id = $response->json()['data']['id'];
|
||||
|
||||
$acars = factory(Acars::class)->make();
|
||||
$acars = Acars::factory()->make();
|
||||
$post_log = [
|
||||
'logs' => [
|
||||
['log' => $acars->log],
|
||||
@@ -878,7 +893,7 @@ class AcarsTest extends TestCase
|
||||
|
||||
$this->assertEquals(1, $body['count']);
|
||||
|
||||
$acars = factory(Acars::class)->make();
|
||||
$acars = Acars::factory()->make();
|
||||
$post_log = [
|
||||
'events' => [
|
||||
['event' => $acars->log],
|
||||
@@ -905,7 +920,7 @@ class AcarsTest extends TestCase
|
||||
$post_route = [];
|
||||
$route_count = random_int(2, 10);
|
||||
|
||||
$route = factory(Navdata::class, $route_count)->create();
|
||||
$route = Navdata::factory()->count($route_count)->create();
|
||||
foreach ($route as $position) {
|
||||
$post_route[] = [
|
||||
'order' => $order,
|
||||
|
||||
Reference in New Issue
Block a user