Code cleanup from inspection results

This commit is contained in:
Nabeel Shahzad
2018-08-26 13:50:08 -05:00
parent 0f3424f41e
commit e95b3eb366
76 changed files with 226 additions and 268 deletions

View File

@@ -24,7 +24,7 @@ class AcarsTest extends TestCase
* @param $points
* @param array $addtl_fields
*/
protected function allPointsInRoute($route, $points, $addtl_fields = [])
protected function allPointsInRoute($route, $points, array $addtl_fields = [])
{
if (empty($addtl_fields)) {
$addtl_fields = [];
@@ -40,7 +40,7 @@ class AcarsTest extends TestCase
$addtl_fields
);
$this->assertEquals(\count($route), \count($points));
$this->assertCount(\count($route), $points);
foreach ($route as $idx => $point) {
$this->assertHasKeys($points[$idx], $fields);
foreach ($fields as $f) {
@@ -556,6 +556,7 @@ class AcarsTest extends TestCase
/**
* Test publishing multiple, batched updates
* @throws Exception
*/
public function testMultipleAcarsPositionUpdates()
{

View File

@@ -71,6 +71,9 @@ class ApiTest extends TestCase
$this->assertTrue(array_key_exists('user', $response['data'][0]));
}
/**
* @throws Exception
*/
public function testGetAirlines()
{
$size = \random_int(5, 10);
@@ -134,6 +137,7 @@ class ApiTest extends TestCase
/**
* Test getting the subfleets
* @throws Exception
*/
public function testGetSubfleets()
{

View File

@@ -123,6 +123,7 @@ class FlightTest extends TestCase
/**
* Get the flight's route
* @throws Exception
*/
public function testFlightRoute()
{
@@ -398,7 +399,7 @@ class FlightTest extends TestCase
$req->assertStatus(200);
$body = $req->json()['data'];
$this->assertEquals(1, count($body['bids']));
$this->assertCount(1, $body['bids']);
$this->assertEquals($flight->id, $body['bids'][0]['flight_id']);
$req = $this->get('/api/users/'.$user->id.'/bids', $headers);
@@ -435,7 +436,7 @@ class FlightTest extends TestCase
$body = $req->json()['data'];
$this->assertEquals($user->id, $body['id']);
$this->assertEquals(0, count($body['bids']));
$this->assertCount(0, $body['bids']);
$req = $this->get('/api/users/'.$user->id.'/bids', $headers);
$req->assertStatus(200);

View File

@@ -35,6 +35,7 @@ class GeoTest extends TestCase
/**
* Make sure the departure airports/sid/star are all filtered out
* @throws Exception
*/
public function testGetCoords()
{

View File

@@ -228,6 +228,7 @@ class ImporterTest extends TestCase
/**
* Test exporting all the flights to a file
* @throws \Illuminate\Validation\ValidationException
*/
public function testAircraftExporter(): void
{

View File

@@ -49,6 +49,9 @@ class PIREPTest extends TestCase
return $saved_route;
}
/**
* @throws Exception
*/
public function testAddPirep()
{
$user = factory(App\Models\User::class)->create();
@@ -59,7 +62,11 @@ class PIREPTest extends TestCase
]);
$pirep = $this->pirepSvc->create($pirep, []);
$this->pirepSvc->saveRoute($pirep);
try {
$this->pirepSvc->saveRoute($pirep);
} catch (Exception $e) {
throw $e;
}
/*
* Check the initial state info

View File

@@ -9,6 +9,7 @@ class RegistrationTest extends TestCase
* A basic test example.
*
* @return void
* @throws Exception
*/
public function testRegistration()
{

View File

@@ -59,10 +59,11 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
{
if ($user !== null) {
$headers['x-api-key'] = $user->api_key;
} else {
if ($this->user !== null) {
$headers['x-api-key'] = $this->user->api_key;
}
return $headers;
}
if ($this->user !== null) {
$headers['x-api-key'] = $this->user->api_key;
}
return $headers;
@@ -90,7 +91,7 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
* @param $obj
* @param array $keys
*/
public function assertHasKeys($obj, $keys = [])
public function assertHasKeys($obj, array $keys = []): void
{
foreach ($keys as $key) {
$this->assertArrayHasKey($key, $obj);

View File

@@ -57,6 +57,7 @@ trait TestData
* @param null $airport_id
*
* @return mixed
* @throws \Exception
*/
public function createSubfleetWithAircraft($aircraft_count = null, $airport_id = null)
{

View File

@@ -14,6 +14,9 @@ class UtilsTest extends TestCase
$this->assertNotNull($carbon);
}
/**
* @throws Exception
*/
public function testSecondsToTimeParts()
{
$t = Utils::secondsToTimeParts(3600);