Fix missing table name in migration and fix flight tests

This commit is contained in:
Nabeel Shahzad
2017-12-12 06:48:04 -06:00
parent a8fafbbee9
commit 2e1c0a75d4
6 changed files with 13 additions and 63 deletions

View File

@@ -1,22 +0,0 @@
<?php
return array(
// which type of store to use.
// valid options: 'json', 'database'
'store' => env('APP_SETTINGS_STORE', 'database'),
// if the json store is used, give the full path to the .json file
// that the store writes to.
'path' => storage_path().'/settings.json',
// if the database store is used, set the name of the table used..
'table' => 'settings',
// If the database store is used, you can set which connection to use. if
// set to null, the default connection will be used.
'connection' => null,
// If you want to use custom column names in database store you could
// set them in this configuration
'keyColumn' => 'key',
'valueColumn' => 'value'
);

View File

@@ -79,6 +79,6 @@ class CreateSettingsTable extends Migration
*/
public function down()
{
Schema::drop($this->tablename);
Schema::drop('settings');
}
}

View File

@@ -114,7 +114,6 @@
<root url="file://$MODULE_DIR$/vendor/barryvdh/laravel-ide-helper" />
<root url="file://$MODULE_DIR$/vendor/barryvdh/reflection-docblock" />
<root url="file://$MODULE_DIR$/vendor/bpocallaghan/generators" />
<root url="file://$MODULE_DIR$/vendor/chrisbjr/api-guard" />
<root url="file://$MODULE_DIR$/vendor/dg/rss-php" />
<root url="file://$MODULE_DIR$/vendor/doctrine/annotations" />
<root url="file://$MODULE_DIR$/vendor/doctrine/cache" />
@@ -124,7 +123,6 @@
<root url="file://$MODULE_DIR$/vendor/doctrine/instantiator" />
<root url="file://$MODULE_DIR$/vendor/egeloen/http-adapter" />
<root url="file://$MODULE_DIR$/vendor/egulias/email-validator" />
<root url="file://$MODULE_DIR$/vendor/ellipsesynergie/api-response" />
<root url="file://$MODULE_DIR$/vendor/filp/whoops" />
<root url="file://$MODULE_DIR$/vendor/fzaninotto/faker" />
<root url="file://$MODULE_DIR$/vendor/guzzlehttp/guzzle" />
@@ -168,8 +166,6 @@
<root url="file://$MODULE_DIR$/vendor/phpunit/php-token-stream" />
<root url="file://$MODULE_DIR$/vendor/phpunit/phpunit" />
<root url="file://$MODULE_DIR$/vendor/phpunit/phpunit-mock-objects" />
<root url="file://$MODULE_DIR$/vendor/pragmarx/version" />
<root url="file://$MODULE_DIR$/vendor/pragmarx/yaml" />
<root url="file://$MODULE_DIR$/vendor/prettus/l5-repository" />
<root url="file://$MODULE_DIR$/vendor/prettus/laravel-validation" />
<root url="file://$MODULE_DIR$/vendor/psr/container" />
@@ -203,7 +199,6 @@
<root url="file://$MODULE_DIR$/vendor/theseer/tokenizer" />
<root url="file://$MODULE_DIR$/vendor/tivie/php-os-detector" />
<root url="file://$MODULE_DIR$/vendor/toin0u/geotools-laravel" />
<root url="file://$MODULE_DIR$/vendor/tremby/laravel-git-version" />
<root url="file://$MODULE_DIR$/vendor/webmozart/assert" />
<root url="file://$MODULE_DIR$/vendor/webpatser/laravel-uuid" />
<root url="file://$MODULE_DIR$/vendor/willdurand/geocoder" />
@@ -217,7 +212,6 @@
<root url="file://$MODULE_DIR$/vendor/barryvdh/laravel-ide-helper" />
<root url="file://$MODULE_DIR$/vendor/barryvdh/reflection-docblock" />
<root url="file://$MODULE_DIR$/vendor/bpocallaghan/generators" />
<root url="file://$MODULE_DIR$/vendor/chrisbjr/api-guard" />
<root url="file://$MODULE_DIR$/vendor/dg/rss-php" />
<root url="file://$MODULE_DIR$/vendor/doctrine/annotations" />
<root url="file://$MODULE_DIR$/vendor/doctrine/cache" />
@@ -227,7 +221,6 @@
<root url="file://$MODULE_DIR$/vendor/doctrine/instantiator" />
<root url="file://$MODULE_DIR$/vendor/egeloen/http-adapter" />
<root url="file://$MODULE_DIR$/vendor/egulias/email-validator" />
<root url="file://$MODULE_DIR$/vendor/ellipsesynergie/api-response" />
<root url="file://$MODULE_DIR$/vendor/filp/whoops" />
<root url="file://$MODULE_DIR$/vendor/fzaninotto/faker" />
<root url="file://$MODULE_DIR$/vendor/guzzlehttp/guzzle" />
@@ -271,8 +264,6 @@
<root url="file://$MODULE_DIR$/vendor/phpunit/php-token-stream" />
<root url="file://$MODULE_DIR$/vendor/phpunit/phpunit" />
<root url="file://$MODULE_DIR$/vendor/phpunit/phpunit-mock-objects" />
<root url="file://$MODULE_DIR$/vendor/pragmarx/version" />
<root url="file://$MODULE_DIR$/vendor/pragmarx/yaml" />
<root url="file://$MODULE_DIR$/vendor/prettus/l5-repository" />
<root url="file://$MODULE_DIR$/vendor/prettus/laravel-validation" />
<root url="file://$MODULE_DIR$/vendor/psr/container" />
@@ -306,7 +297,6 @@
<root url="file://$MODULE_DIR$/vendor/theseer/tokenizer" />
<root url="file://$MODULE_DIR$/vendor/tivie/php-os-detector" />
<root url="file://$MODULE_DIR$/vendor/toin0u/geotools-laravel" />
<root url="file://$MODULE_DIR$/vendor/tremby/laravel-git-version" />
<root url="file://$MODULE_DIR$/vendor/webmozart/assert" />
<root url="file://$MODULE_DIR$/vendor/webpatser/laravel-uuid" />
<root url="file://$MODULE_DIR$/vendor/willdurand/geocoder" />

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}