Fixed styleCi errors

This commit is contained in:
Mac 2022-12-06 02:52:37 +01:00
parent d877c3071c
commit af45bc7e49

View File

@ -19,7 +19,6 @@ use App\Repositories\SettingRepository;
use App\Support\Utils; use App\Support\Utils;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Testing\TestResponse; use Illuminate\Testing\TestResponse;
use function count; use function count;
use function random_int; use function random_int;
@ -74,7 +73,7 @@ class AcarsTest extends TestCase
protected function getPirep(string $pirep_id): array protected function getPirep(string $pirep_id): array
{ {
return $this->get('/api/pireps/' . $pirep_id)->assertOk()->json('data'); return $this->get('/api/pireps/'.$pirep_id)->assertOk()->json('data');
} }
/** /**
@ -250,7 +249,7 @@ class AcarsTest extends TestCase
$this->assertEquals('custom_value', $field['value']); $this->assertEquals('custom_value', $field['value']);
//Try to update fields //Try to update fields
$this->post('/api/pireps/' . $pirepID . '/update', [ $this->post('/api/pireps/'.$pirepID.'/update', [
'fares' => [ 'fares' => [
[ [
'id' => $fare->id, 'id' => $fare->id,
@ -265,10 +264,10 @@ class AcarsTest extends TestCase
$this->assertEquals($fare->capacity, $saved_fare['count']); $this->assertEquals($fare->capacity, $saved_fare['count']);
//Try cancelling the PIREP now //Try cancelling the PIREP now
$this->put('/api/pireps/' . $pirepID . '/cancel', [])->assertOk(); $this->put('/api/pireps/'.$pirepID.'/cancel', [])->assertOk();
// Read it // Read it
$this->get('/api/pireps/' . $pirepID) $this->get('/api/pireps/'.$pirepID)
->assertOk() ->assertOk()
->assertJsonPath('data.state', PirepState::CANCELLED); ->assertJsonPath('data.state', PirepState::CANCELLED);
} }
@ -297,7 +296,7 @@ class AcarsTest extends TestCase
->json('data'); ->json('data');
//Try to update fields //Try to update fields
$this->post('/api/pireps/' . $pirep['id'] . '/update', ['dpt_airport_id' => '']) $this->post('/api/pireps/'.$pirep['id'].'/update', ['dpt_airport_id' => ''])
->assertStatus(400) ->assertStatus(400)
->assertJsonPath('details', 'A departure airport is required') ->assertJsonPath('details', 'A departure airport is required')
->json('details'); ->json('details');
@ -305,6 +304,7 @@ class AcarsTest extends TestCase
/** /**
* Post a PIREP into a PREFILE state and post ACARS * Post a PIREP into a PREFILE state and post ACARS
*
* @throws \Exception * @throws \Exception
*/ */
public function testAcarsUpdates() public function testAcarsUpdates()
@ -358,7 +358,7 @@ class AcarsTest extends TestCase
$this->assertHasKeys($pirep['planned_distance'], ['mi', 'nmi', 'km']); $this->assertHasKeys($pirep['planned_distance'], ['mi', 'nmi', 'km']);
//Update the custom field //Update the custom field
$this->post('/api/pireps/' . $pirep_id . '/update', [ $this->post('/api/pireps/'.$pirep_id.'/update', [
'flight_time' => 60, 'flight_time' => 60,
'distance' => 20, 'distance' => 20,
'status' => PirepStatus::AIRBORNE, 'status' => PirepStatus::AIRBORNE,
@ -371,7 +371,7 @@ class AcarsTest extends TestCase
$this->assertEquals('custom_value_changed', $pirep['fields']['custom_field']); $this->assertEquals('custom_value_changed', $pirep['fields']['custom_field']);
//Add some position updates //Add some position updates
$uri = '/api/pireps/' . $pirep_id . '/acars/position'; $uri = '/api/pireps/'.$pirep_id.'/acars/position';
// Test missing positions field // Test missing positions field
// Post an ACARS update // Post an ACARS update
@ -400,7 +400,7 @@ class AcarsTest extends TestCase
->assertJsonPath('data.0.lon', fn (float $longitude) => round($longitude, 2) === round($acars['lon'], 2)); ->assertJsonPath('data.0.lon', fn (float $longitude) => round($longitude, 2) === round($acars['lon'], 2));
// Update fields standalone // Update fields standalone
$this->post('/api/pireps/' . $pirep_id . '/fields', [ $this->post('/api/pireps/'.$pirep_id.'/fields', [
'fields' => [ 'fields' => [
'Departure Gate' => 'G26', 'Departure Gate' => 'G26',
], ],
@ -420,7 +420,7 @@ class AcarsTest extends TestCase
//File the PIREP //File the PIREP
$filePirepUri = '/api/pireps/' . $pirep_id . '/file'; $filePirepUri = '/api/pireps/'.$pirep_id.'/file';
$this->post($filePirepUri, []) $this->post($filePirepUri, [])
->assertJsonValidationErrors(['flight_time']) ->assertJsonValidationErrors(['flight_time'])
->assertStatus(400); // missing field ->assertStatus(400); // missing field
@ -436,7 +436,7 @@ class AcarsTest extends TestCase
])->assertOk(); ])->assertOk();
// Add a comment // Add a comment
$commentUri = '/api/pireps/' . $pirep_id . '/comments'; $commentUri = '/api/pireps/'.$pirep_id.'/comments';
$this->post($commentUri, ['comment' => 'A comment'])->assertCreated(); $this->post($commentUri, ['comment' => 'A comment'])->assertCreated();
$this->get($commentUri)->assertOk(200)->assertJsonCount(1); $this->get($commentUri)->assertOk(200)->assertJsonCount(1);
} }
@ -467,7 +467,7 @@ class AcarsTest extends TestCase
->json('data.id'); ->json('data.id');
// File the PIREP now // File the PIREP now
$filePirepUri = '/api/pireps/' . $pirep_id . '/file'; $filePirepUri = '/api/pireps/'.$pirep_id.'/file';
$this->post($filePirepUri, [ $this->post($filePirepUri, [
'flight_time' => 130, 'flight_time' => 130,
'fuel_used' => 8000.19, 'fuel_used' => 8000.19,
@ -475,7 +475,7 @@ class AcarsTest extends TestCase
])->assertStatus(200); ])->assertStatus(200);
// Check the block_off_time and block_on_time being set // Check the block_off_time and block_on_time being set
$this->get('/api/pireps/' . $pirep_id) $this->get('/api/pireps/'.$pirep_id)
->assertJsonPath('data.state', PirepState::PENDING) ->assertJsonPath('data.state', PirepState::PENDING)
->assertJsonPath('data.block_off_time', fn (?string $dateTime) => $dateTime !== null) ->assertJsonPath('data.block_off_time', fn (?string $dateTime) => $dateTime !== null)
->assertJsonPath('data.block_on_time', fn (?string $dateTime) => $dateTime !== null); ->assertJsonPath('data.block_on_time', fn (?string $dateTime) => $dateTime !== null);
@ -564,7 +564,7 @@ class AcarsTest extends TestCase
->assertStatus(200) ->assertStatus(200)
->json('data.id'); ->json('data.id');
$uri = '/api/pireps/' . $pirep_id . '/acars/position'; $uri = '/api/pireps/'.$pirep_id.'/acars/position';
// Post an ACARS update // Post an ACARS update
$acars_count = random_int(5, 10); $acars_count = random_int(5, 10);
@ -611,7 +611,7 @@ class AcarsTest extends TestCase
$pirep_id = $this->createPirepResponse($this->createPirep()->toArray())->assertOk()->json('data.id'); $pirep_id = $this->createPirepResponse($this->createPirep()->toArray())->assertOk()->json('data.id');
$acars = Acars::factory()->make(['sim_time' => date('c')])->toArray(); $acars = Acars::factory()->make(['sim_time' => date('c')])->toArray();
$this->post('/api/pireps/' . $pirep_id . '/acars/position', ['positions' => [$acars]])->assertOk(); $this->post('/api/pireps/'.$pirep_id.'/acars/position', ['positions' => [$acars]])->assertOk();
} }
/** /**
@ -622,7 +622,7 @@ class AcarsTest extends TestCase
$pirep_id = $this->createPirepResponse($this->createPirep()->toArray())->assertOk()->json('data.id'); $pirep_id = $this->createPirepResponse($this->createPirep()->toArray())->assertOk()->json('data.id');
// Missing lat/lon // Missing lat/lon
$uri = '/api/pireps/' . $pirep_id . '/route'; $uri = '/api/pireps/'.$pirep_id.'/route';
$this->post($uri, ['order' => 1, 'name' => 'NAVPOINT'])->assertStatus(400); $this->post($uri, ['order' => 1, 'name' => 'NAVPOINT'])->assertStatus(400);
$this->post($uri, [ $this->post($uri, [
@ -643,14 +643,14 @@ class AcarsTest extends TestCase
{ {
$pirep_id = $this->createPirepResponse($this->createPirep()->toArray())->json('data.id'); $pirep_id = $this->createPirepResponse($this->createPirep()->toArray())->json('data.id');
$this->post('/api/pireps/' . $pirep_id . '/acars/logs', [ $this->post('/api/pireps/'.$pirep_id.'/acars/logs', [
'logs' => [ 'logs' => [
['log' => Acars::factory()->make()->log], ['log' => Acars::factory()->make()->log],
], ],
])->assertOk() ])->assertOk()
->assertJsonPath('count', 1); ->assertJsonPath('count', 1);
$this->post('/api/pireps/' . $pirep_id . '/acars/events', [ $this->post('/api/pireps/'.$pirep_id.'/acars/events', [
'events' => [ 'events' => [
['event' => Acars::factory()->make()->log], ['event' => Acars::factory()->make()->log],
], ],
@ -661,7 +661,7 @@ class AcarsTest extends TestCase
public function testAcarsRoutePost() public function testAcarsRoutePost()
{ {
$pirep_id = $this->createPirepResponse($this->createPirep()->toArray())->assertOk()->json('data.id'); $pirep_id = $this->createPirepResponse($this->createPirep()->toArray())->assertOk()->json('data.id');
$uri = '/api/pireps/' . $pirep_id . '/route'; $uri = '/api/pireps/'.$pirep_id.'/route';
$order = 1; $order = 1;
$post_route = []; $post_route = [];