Fix tests

This commit is contained in:
Nabeel Shahzad 2021-06-10 13:13:09 -04:00
parent 531489bfde
commit 845514da2c
3 changed files with 8 additions and 5 deletions

View File

@ -30,7 +30,7 @@ class AirlineController extends Controller
*/
public function index(Request $request)
{
$airports = $this->airlineRepo->whereOrder(['active' => true], 'name');
$airports = $this->airlineRepo->whereOrder(['active' => true], 'name')->get();
return AirlineResource::collection($airports);
}

View File

@ -534,6 +534,9 @@ class RouteServiceProvider extends ServiceProvider
Route::get('fleet', 'FleetController@index');
Route::get('fleet/aircraft/{id}', 'FleetController@get_aircraft');
Route::get('subfleet', 'FleetController@index');
Route::get('subfleet/aircraft/{id}', 'FleetController@get_aircraft');
Route::get('flights', 'FlightController@index');
Route::get('flights/search', 'FlightController@search');
Route::get('flights/{id}', 'FlightController@get');

View File

@ -144,14 +144,14 @@ class ApiTest extends TestCase
'airline_id' => 0,
]);
factory(Airline::class, $size)->create();
factory(Subfleet::class, $size)->create();
/*
* Page 0 and page 1 should return the same thing
*/
// Test pagination
$res = $this->get('/api/airlines?limit=1&page=0');
$res = $this->get('/api/fleet?limit=1&page=0');
$this->assertTrue($res->isOk());
$body = $res->json('data');
@ -159,7 +159,7 @@ class ApiTest extends TestCase
$id_first = $body[0]['id'];
$res = $this->get('/api/airlines?limit=1&page=1');
$res = $this->get('/api/fleet?limit=1&page=1');
$this->assertTrue($res->isOk());
$body = $res->json('data');
@ -171,7 +171,7 @@ class ApiTest extends TestCase
* Page 2 should be different from page 1
*/
$res = $this->get('/api/airlines?limit=1&page=2');
$res = $this->get('/api/fleet?limit=1&page=2');
$this->assertTrue($res->isOk());
$body = $res->json('data');