Fix missing table name in migration and fix flight tests
This commit is contained in:
@@ -5,10 +5,6 @@
|
||||
*/
|
||||
class ApiTest extends TestCase
|
||||
{
|
||||
protected static $headers = [
|
||||
'Authorization' => 'testapikey'
|
||||
];
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -30,7 +26,7 @@ class ApiTest extends TestCase
|
||||
->assertStatus(401);
|
||||
|
||||
// Test upper/lower case of Authorization header, etc
|
||||
$this->withHeaders(self::$headers)->get($uri)
|
||||
$this->withHeaders(self::$auth_headers)->get($uri)
|
||||
->assertStatus(200)
|
||||
->assertJson(['icao' => 'KJFK'], true);
|
||||
|
||||
@@ -44,11 +40,11 @@ class ApiTest extends TestCase
|
||||
*/
|
||||
public function testAirportRequest()
|
||||
{
|
||||
$this->withHeaders(self::$headers)->get('/api/airports/KJFK')
|
||||
$this->withHeaders(self::$auth_headers)->get('/api/airports/KJFK')
|
||||
->assertStatus(200)
|
||||
->assertJson(['icao' => 'KJFK'], true);
|
||||
|
||||
$this->withHeaders(self::$headers)->get('/api/airports/UNK')
|
||||
$this->withHeaders(self::$auth_headers)->get('/api/airports/UNK')
|
||||
->assertStatus(404);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ class FlightTest extends TestCase
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->addData('base');
|
||||
}
|
||||
|
||||
@@ -15,34 +14,17 @@ class FlightTest extends TestCase
|
||||
$flight = new App\Models\Flight;
|
||||
$flight->airline_id = 1;
|
||||
$flight->flight_number = 10;
|
||||
$flight->dpt_airport_id = 1;
|
||||
$flight->arr_airport_id = 2;
|
||||
$flight->dpt_airport_id = 'KAUS';
|
||||
$flight->arr_airport_id = 'KJFK';
|
||||
$flight->save();
|
||||
|
||||
return $flight->id;
|
||||
}
|
||||
|
||||
public function testGetFlight()
|
||||
{
|
||||
$flight_id = $this->addFlight();
|
||||
$response = $this->json('GET', '/api/flight/'.$flight_id);
|
||||
/*$response->assertStatus(200);
|
||||
$response->assertJson(['data' => true]);*/
|
||||
}
|
||||
|
||||
/**
|
||||
* mainly to test the model relationships work correctly
|
||||
*/
|
||||
public function XtestAddFlight()
|
||||
{
|
||||
$this->markTestSkipped(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
|
||||
$this->addFlight();
|
||||
|
||||
$flight = App\Models\Flight::where('flight_number', 100)->first();
|
||||
|
||||
$this->assertEquals($flight->dpt_airport->icao, 'KAUS');
|
||||
$this->assertEquals($flight->arr_airport->icao, 'KJFK');
|
||||
$this->get('/api/flight/'.$flight_id, self::$auth_headers)
|
||||
->assertStatus(200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
protected $baseUrl = 'http://localhost';
|
||||
protected $connectionsToTransact = ['testing'];
|
||||
|
||||
protected static $auth_headers = [
|
||||
'Authorization' => 'testapikey'
|
||||
];
|
||||
|
||||
public function __construct($name = null, array $data = [], $dataName = '') {
|
||||
parent::__construct($name, $data, $dataName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user