389 API Changes (#393)

* Update PHPUnit to 8

* Fix API endpoints closes #389

* Update pagination method in Repository contract to look at the page number closes #390

* Remove unused imports

* Fix tests in FlightTests

* Typecast page

* Don't register factories

* Remove Factory loading

* Remove unused imports
This commit is contained in:
Nabeel S
2019-09-13 11:21:40 -04:00
committed by GitHub
parent 23eb9dcbda
commit d68d8791bd
21 changed files with 230 additions and 172 deletions

1
.gitignore vendored
View File

@@ -1,6 +1,7 @@
_ide_helper.php
.php_cs.cache
.phpstorm.meta.php
.phpunit.result.cache
/vendor
node_modules/
npm-debug.log

View File

@@ -66,6 +66,7 @@ if [ "$TRAVIS" = "true" ]; then
.php_cs.cache
.phpstorm.meta.php
.styleci.yml
.phpunit.result.cache
env.php
intellij_style.xml
config.php

View File

@@ -108,4 +108,32 @@ abstract class Repository extends \Prettus\Repository\Eloquent\BaseRepository
return $q;
});
}
/**
* Retrieve all data of repository, paginated. Added in extra parameter to read from the
* request which page it should be on
*
* @param null $limit
* @param array $columns
* @param string $method
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*
* @return mixed
*/
public function paginate($limit = null, $columns = ['*'], $method = 'paginate')
{
$this->applyCriteria();
$this->applyScope();
$max = config('repository.pagination.limit', 50);
$limit = (int) ($limit ?? request()->query('limit') ?? $max);
$page = (int) request()->query('page', 1);
$results = $this->model->{$method}($limit, $columns, 'page', $page);
$results->appends(app('request')->query());
$this->resetModel();
return $this->parserResult($results);
}
}

View File

@@ -8,6 +8,7 @@ use App\Http\Requests\Acars\EventRequest;
use App\Http\Requests\Acars\LogRequest;
use App\Http\Requests\Acars\PositionRequest;
use App\Http\Resources\AcarsRoute as AcarsRouteResource;
use App\Http\Resources\Pirep as PirepResource;
use App\Models\Acars;
use App\Models\Enums\AcarsType;
use App\Models\Enums\PirepStatus;
@@ -21,9 +22,6 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
/**
* Class AcarsController
*/
class AcarsController extends Controller
{
private $acarsRepo;
@@ -61,6 +59,20 @@ class AcarsController extends Controller
}
}
/**
* Get all the active PIREPs
*
* @return mixed
*/
public function live_flights()
{
$pireps = $this->acarsRepo->getPositions(setting('acars.live_time'))->filter(function ($pirep) {
return $pirep->position !== null;
});
return PirepResource::collection($pireps);
}
/**
* Return all of the flights (as points) in GeoJSON format
*
@@ -68,7 +80,7 @@ class AcarsController extends Controller
*
* @return mixed
*/
public function index(Request $request)
public function pireps_geojson(Request $request)
{
$pireps = $this->acarsRepo->getPositions(setting('acars.live_time'));
$positions = $this->geoSvc->getFeatureForLiveFlights($pireps);

View File

@@ -7,9 +7,6 @@ use App\Http\Resources\Airline as AirlineResource;
use App\Repositories\AirlineRepository;
use Illuminate\Http\Request;
/**
* Class AirlineController
*/
class AirlineController extends Controller
{
private $airlineRepo;
@@ -34,7 +31,6 @@ class AirlineController extends Controller
*/
public function index(Request $request)
{
//$this->airlineRepo->pushCriteria(new RequestCriteria($request));
$airports = $this->airlineRepo
->whereOrder(['active' => true], 'name', 'asc')
->paginate();

View File

@@ -33,10 +33,10 @@ use App\Services\FareService;
use App\Services\Finance\PirepFinanceService;
use App\Services\PirepService;
use App\Services\UserService;
use Auth;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Log;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
/**
* Class PirepController
@@ -52,8 +52,6 @@ class PirepController extends Controller
private $userSvc;
/**
* PirepController constructor.
*
* @param AcarsRepository $acarsRepo
* @param FareService $fareSvc
* @param PirepFinanceService $financeSvc
@@ -159,22 +157,6 @@ class PirepController extends Controller
$this->fareSvc->saveForPirep($pirep, $fares);
}
/**
* Get all the active PIREPs
*
* @return mixed
*/
public function index()
{
$pireps = $this->acarsRepo
->getPositions(setting('acars.live_time'))
->filter(function ($pirep) {
return $pirep->position !== null;
});
return PirepResource::collection($pireps);
}
/**
* @param $pirep_id
*

View File

@@ -4,8 +4,9 @@
* Public routes
*/
Route::group([], function () {
Route::get('acars', 'AcarsController@index');
Route::get('pireps', 'PirepController@index');
Route::get('acars', 'AcarsController@live_flights');
Route::get('acars/geojson', 'AcarsController@pireps_geojson');
Route::get('pireps/{pirep_id}', 'PirepController@get');
Route::get('pireps/{pirep_id}/acars/geojson', 'AcarsController@acars_geojson');
@@ -15,7 +16,7 @@ Route::group([], function () {
});
/*
* these need to be authenticated with a user's API key
* These need to be authenticated with a user's API key
*/
Route::group(['middleware' => ['api.auth']], function () {
Route::get('airlines', 'AirlineController@index');
@@ -35,6 +36,7 @@ Route::group(['middleware' => ['api.auth']], function () {
Route::get('flights/{id}', 'FlightController@get');
Route::get('flights/{id}/route', 'FlightController@route');
Route::get('pireps', 'UserController@pireps');
Route::put('pireps/{pirep_id}', 'PirepController@update');
/*

View File

@@ -34,7 +34,7 @@
"league/geotools": "0.8.*",
"league/iso3166": "2.1.*",
"markrogoyski/math-php": "^0.38.0",
"myclabs/deep-copy": "1.8.*",
"myclabs/deep-copy": "~1.9.0",
"nabeel/vacentral": "~2.0",
"nwidart/laravel-modules": "~5.1",
"php-units-of-measure/php-units-of-measure": "~2.1.0",
@@ -60,8 +60,8 @@
"fzaninotto/faker": "~1.8.0",
"friendsofphp/php-cs-fixer": "^2.15",
"mockery/mockery": "0.9.*",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "7.5.*",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "~8.3",
"squizlabs/php_codesniffer": "3.*"
},
"autoload": {

182
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0dc48b4cd01f28ea3f900ca23529803f",
"content-hash": "36efcc47f7cb692d56b1fe62108d86a1",
"packages": [
{
"name": "akaunting/money",
@@ -1489,16 +1489,16 @@
},
{
"name": "facade/ignition",
"version": "1.6.3",
"version": "1.6.4",
"source": {
"type": "git",
"url": "https://github.com/facade/ignition.git",
"reference": "69d7687cb9a4b43978c532b46f05dcdd80be812c"
"reference": "43b825a2f77805d1d5495c64eecd272b05ab0e33"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facade/ignition/zipball/69d7687cb9a4b43978c532b46f05dcdd80be812c",
"reference": "69d7687cb9a4b43978c532b46f05dcdd80be812c",
"url": "https://api.github.com/repos/facade/ignition/zipball/43b825a2f77805d1d5495c64eecd272b05ab0e33",
"reference": "43b825a2f77805d1d5495c64eecd272b05ab0e33",
"shasum": ""
},
"require": {
@@ -1553,7 +1553,7 @@
"laravel",
"page"
],
"time": "2019-09-12T12:36:31+00:00"
"time": "2019-09-13T07:41:17+00:00"
},
{
"name": "facade/ignition-contracts",
@@ -3055,16 +3055,16 @@
},
{
"name": "myclabs/deep-copy",
"version": "1.8.1",
"version": "1.9.3",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8"
"reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8",
"reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/007c053ae6f31bba39dfa19a7726f56e9763bbea",
"reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea",
"shasum": ""
},
"require": {
@@ -3099,7 +3099,7 @@
"object",
"object graph"
],
"time": "2018-06-11T23:09:50+00:00"
"time": "2019-08-09T12:45:53+00:00"
},
{
"name": "nabeel/vacentral",
@@ -7750,16 +7750,16 @@
},
{
"name": "nunomaduro/collision",
"version": "v2.1.1",
"version": "v3.0.1",
"source": {
"type": "git",
"url": "https://github.com/nunomaduro/collision.git",
"reference": "b5feb0c0d92978ec7169232ce5d70d6da6b29f63"
"reference": "af42d339fe2742295a54f6fdd42aaa6f8c4aca68"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nunomaduro/collision/zipball/b5feb0c0d92978ec7169232ce5d70d6da6b29f63",
"reference": "b5feb0c0d92978ec7169232ce5d70d6da6b29f63",
"url": "https://api.github.com/repos/nunomaduro/collision/zipball/af42d339fe2742295a54f6fdd42aaa6f8c4aca68",
"reference": "af42d339fe2742295a54f6fdd42aaa6f8c4aca68",
"shasum": ""
},
"require": {
@@ -7769,10 +7769,10 @@
"symfony/console": "~2.8|~3.3|~4.0"
},
"require-dev": {
"laravel/framework": "5.7.*",
"laravel/framework": "5.8.*",
"nunomaduro/larastan": "^0.3.0",
"phpstan/phpstan": "^0.10",
"phpunit/phpunit": "~7.3"
"phpstan/phpstan": "^0.11",
"phpunit/phpunit": "~8.0"
},
"type": "library",
"extra": {
@@ -7810,7 +7810,7 @@
"php",
"symfony"
],
"time": "2018-11-21T21:40:54+00:00"
"time": "2019-03-07T21:35:13+00:00"
},
{
"name": "phar-io/manifest",
@@ -8180,40 +8180,40 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "6.1.4",
"version": "7.0.7",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d"
"reference": "7743bbcfff2a907e9ee4a25be13d0f8ec5e73800"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d",
"reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7743bbcfff2a907e9ee4a25be13d0f8ec5e73800",
"reference": "7743bbcfff2a907e9ee4a25be13d0f8ec5e73800",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-xmlwriter": "*",
"php": "^7.1",
"phpunit/php-file-iterator": "^2.0",
"php": "^7.2",
"phpunit/php-file-iterator": "^2.0.2",
"phpunit/php-text-template": "^1.2.1",
"phpunit/php-token-stream": "^3.0",
"phpunit/php-token-stream": "^3.1.0",
"sebastian/code-unit-reverse-lookup": "^1.0.1",
"sebastian/environment": "^3.1 || ^4.0",
"sebastian/environment": "^4.2.2",
"sebastian/version": "^2.0.1",
"theseer/tokenizer": "^1.1"
"theseer/tokenizer": "^1.1.3"
},
"require-dev": {
"phpunit/phpunit": "^7.0"
"phpunit/phpunit": "^8.2.2"
},
"suggest": {
"ext-xdebug": "^2.6.0"
"ext-xdebug": "^2.7.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "6.1-dev"
"dev-master": "7.0-dev"
}
},
"autoload": {
@@ -8239,7 +8239,7 @@
"testing",
"xunit"
],
"time": "2018-10-31T16:06:48+00:00"
"time": "2019-07-25T05:31:54+00:00"
},
{
"name": "phpunit/php-file-iterator",
@@ -8432,53 +8432,52 @@
},
{
"name": "phpunit/phpunit",
"version": "7.5.15",
"version": "8.3.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "d79c053d972856b8b941bb233e39dc521a5093f0"
"reference": "e31cce0cf4499c0ccdbbb211a3280d36ab341e36"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d79c053d972856b8b941bb233e39dc521a5093f0",
"reference": "d79c053d972856b8b941bb233e39dc521a5093f0",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e31cce0cf4499c0ccdbbb211a3280d36ab341e36",
"reference": "e31cce0cf4499c0ccdbbb211a3280d36ab341e36",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.1",
"doctrine/instantiator": "^1.2.0",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-xml": "*",
"myclabs/deep-copy": "^1.7",
"phar-io/manifest": "^1.0.2",
"phar-io/version": "^2.0",
"php": "^7.1",
"phpspec/prophecy": "^1.7",
"phpunit/php-code-coverage": "^6.0.7",
"phpunit/php-file-iterator": "^2.0.1",
"ext-xmlwriter": "*",
"myclabs/deep-copy": "^1.9.1",
"phar-io/manifest": "^1.0.3",
"phar-io/version": "^2.0.1",
"php": "^7.2",
"phpspec/prophecy": "^1.8.1",
"phpunit/php-code-coverage": "^7.0.7",
"phpunit/php-file-iterator": "^2.0.2",
"phpunit/php-text-template": "^1.2.1",
"phpunit/php-timer": "^2.1",
"sebastian/comparator": "^3.0",
"sebastian/diff": "^3.0",
"sebastian/environment": "^4.0",
"sebastian/exporter": "^3.1",
"sebastian/global-state": "^2.0",
"phpunit/php-timer": "^2.1.2",
"sebastian/comparator": "^3.0.2",
"sebastian/diff": "^3.0.2",
"sebastian/environment": "^4.2.2",
"sebastian/exporter": "^3.1.0",
"sebastian/global-state": "^3.0.0",
"sebastian/object-enumerator": "^3.0.3",
"sebastian/resource-operations": "^2.0",
"sebastian/resource-operations": "^2.0.1",
"sebastian/type": "^1.1.3",
"sebastian/version": "^2.0.1"
},
"conflict": {
"phpunit/phpunit-mock-objects": "*"
},
"require-dev": {
"ext-pdo": "*"
},
"suggest": {
"ext-soap": "*",
"ext-xdebug": "*",
"phpunit/php-invoker": "^2.0"
"phpunit/php-invoker": "^2.0.0"
},
"bin": [
"phpunit"
@@ -8486,7 +8485,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "7.5-dev"
"dev-master": "8.3-dev"
}
},
"autoload": {
@@ -8501,8 +8500,8 @@
"authors": [
{
"name": "Sebastian Bergmann",
"role": "lead",
"email": "sebastian@phpunit.de"
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "The PHP Unit Testing framework.",
@@ -8512,7 +8511,7 @@
"testing",
"xunit"
],
"time": "2019-08-21T07:05:16+00:00"
"time": "2019-08-11T06:56:55+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@@ -8801,23 +8800,26 @@
},
{
"name": "sebastian/global-state",
"version": "2.0.0",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4"
"reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4",
"reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4",
"reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4",
"shasum": ""
},
"require": {
"php": "^7.0"
"php": "^7.2",
"sebastian/object-reflector": "^1.1.1",
"sebastian/recursion-context": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
"ext-dom": "*",
"phpunit/phpunit": "^8.0"
},
"suggest": {
"ext-uopz": "*"
@@ -8825,7 +8827,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
"dev-master": "3.0-dev"
}
},
"autoload": {
@@ -8848,7 +8850,7 @@
"keywords": [
"global state"
],
"time": "2017-04-27T15:39:26+00:00"
"time": "2019-02-01T05:30:01+00:00"
},
{
"name": "sebastian/object-enumerator",
@@ -9037,6 +9039,52 @@
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"time": "2018-10-04T04:07:39+00:00"
},
{
"name": "sebastian/type",
"version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/type.git",
"reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/3aaaa15fa71d27650d62a948be022fe3b48541a3",
"reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3",
"shasum": ""
},
"require": {
"php": "^7.2"
},
"require-dev": {
"phpunit/phpunit": "^8.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Collection of value objects that represent the types of the PHP type system",
"homepage": "https://github.com/sebastianbergmann/type",
"time": "2019-07-02T08:10:15+00:00"
},
{
"name": "sebastian/version",
"version": "2.0.1",

View File

@@ -1,20 +1,8 @@
<?php
/*
|--------------------------------------------------------------------------
| Prettus Repository Config
|--------------------------------------------------------------------------
|
|
*/
return [
/*
|--------------------------------------------------------------------------
| Repository Pagination Limit Default
|--------------------------------------------------------------------------
|
*/
'pagination' => [
'limit' => 15,
'limit' => 50,
],
/*

View File

@@ -3,7 +3,6 @@
namespace Modules\Installer\Providers;
use App\Services\ModuleService;
use Illuminate\Database\Eloquent\Factory;
use Illuminate\Support\ServiceProvider;
use Route;
@@ -23,7 +22,6 @@ class InstallerServiceProvider extends ServiceProvider
$this->registerConfig();
$this->registerViews();
$this->registerFactories();
$this->loadMigrationsFrom(__DIR__.'/../Database/migrations');
}
@@ -102,18 +100,6 @@ class InstallerServiceProvider extends ServiceProvider
}
}
/**
* Register an additional directory of factories.
*
* @source https://github.com/sebastiaanluca/laravel-resource-flow/blob/develop/src/Modules/ModuleServiceProvider.php#L66
*/
public function registerFactories()
{
if (!app()->environment('production')) {
app(Factory::class)->load(__DIR__.'/../Database/factories');
}
}
/**
* Get the services provided by the provider.
*/

View File

@@ -3,7 +3,6 @@
namespace Modules\Sample\Providers;
use App\Services\ModuleService;
use Illuminate\Database\Eloquent\Factory;
use Illuminate\Support\ServiceProvider;
use Route;
@@ -25,7 +24,6 @@ class SampleServiceProvider extends ServiceProvider
$this->registerLinks();
$this->registerFactories();
$this->loadMigrationsFrom(__DIR__.'/../Database/migrations');
}
@@ -145,18 +143,6 @@ class SampleServiceProvider extends ServiceProvider
}
}
/**
* Register an additional directory of factories.
*
* @source https://github.com/sebastiaanluca/laravel-resource-flow/blob/develop/src/Modules/ModuleServiceProvider.php#L66
*/
public function registerFactories()
{
if (!app()->environment('production')) {
app(Factory::class)->load(__DIR__.'/../Database/factories');
}
}
/**
* Get the services provided by the provider.
*/

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,19 +1,14 @@
{
"/assets/frontend/js/app.js": "/assets/frontend/js/app.js?id=daeb52631a6f290bb107",
"/assets/frontend/js/app.js": "/assets/frontend/js/app.js?id=eccdf193a37c5af46fd3",
"/assets/frontend/css/now-ui-kit.css": "/assets/frontend/css/now-ui-kit.css?id=b2dd2a0a882054cad3d5",
"/assets/admin/css/vendor.min.css": "/assets/admin/css/vendor.min.css?id=9f24c5e6612e74065901",
"/assets/frontend/js/app.js.map": "/assets/frontend/js/app.js.map?id=2ec8669fae475c273eb7",
"/assets/frontend/js/app.js.map": "/assets/frontend/js/app.js.map?id=5a7f5ff244b2e68e2e97",
"/assets/frontend/css/now-ui-kit.css.map": "/assets/frontend/css/now-ui-kit.css.map?id=6399f2da87c32423e68b",
"/assets/admin/css/vendor.min.css.map": "/assets/admin/css/vendor.min.css.map?id=c266c31652dea865307c",
"/assets/admin/js/app.js": "/assets/admin/js/app.js?id=e813d47f6754d5d1ea9a",
"/assets/admin/js/app.js.map": "/assets/admin/js/app.js.map?id=365fd03d366b4d04c930",
"/assets/admin/js/app.js": "/assets/admin/js/app.js?id=04a35bc7089e2c0465f7",
"/assets/admin/js/app.js.map": "/assets/admin/js/app.js.map?id=585453e7f6a36a7cd888",
"/assets/installer/js/app.js": "/assets/installer/js/app.js?id=7eb8b66dce0064082abc",
"/assets/installer/js/app.js.map": "/assets/installer/js/app.js.map?id=8d818e1a57d346adf7b3",
"/assets/vendor/bootstrap/4.3/css/bootstrap.min.css": "/assets/vendor/bootstrap/4.3/css/bootstrap.min.css?id=a15c2ac3234aa8f6064e",
"/assets/vendor/bootstrap/4.3/css/bootstrap.min.css.map": "/assets/vendor/bootstrap/4.3/css/bootstrap.min.css.map?id=1ac01d0e0892441d8eb1",
"/assets/vendor/bootstrap/4.3/js/bootstrap.js": "/assets/vendor/bootstrap/4.3/js/bootstrap.js?id=7f827fe484ec04346553",
"/assets/vendor/bootstrap/3.4/css/bootstrap.css": "/assets/vendor/bootstrap/3.4/css/bootstrap.css?id=2dbb985a5bb6dd8ef0a7",
"/assets/vendor/bootstrap/3.4/css/bootstrap.min.css": "/assets/vendor/bootstrap/3.4/css/bootstrap.min.css?id=7f89537eaf606bff49f5",
"/assets/fonts/glyphicons-halflings-regular.woff2": "/assets/fonts/glyphicons-halflings-regular.woff2?id=349344e92fb16221dd56",
"/assets/admin/fonts/glyphicons-halflings-regular.woff2": "/assets/admin/fonts/glyphicons-halflings-regular.woff2?id=349344e92fb16221dd56",
"/assets/admin/img/clear.png": "/assets/admin/img/clear.png?id=63b3af84650a0145d61a",

View File

@@ -19,7 +19,7 @@ export default (_opts) => {
center: [29.98139, -95.33374],
refresh_interval: 10, // seconds
zoom: 5,
update_uri: '/api/acars',
update_uri: '/api/acars/geojson',
pirep_uri: '/api/pireps/{id}',
pirep_link_uri: '/pireps/{id}',
positions: null,

View File

@@ -3,7 +3,6 @@
namespace $NAMESPACE$;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory;
use Route;
/**
@@ -30,7 +29,6 @@ class $CLASS$ extends ServiceProvider
$this->registerLinks();
$this->registerFactories();
$this->loadMigrationsFrom(__DIR__ . '/../$MIGRATIONS_PATH$');
}
@@ -144,17 +142,6 @@ class $CLASS$ extends ServiceProvider
}
}
/**
* Register an additional directory of factories.
* @source https://github.com/sebastiaanluca/laravel-resource-flow/blob/develop/src/Modules/ModuleServiceProvider.php#L66
*/
public function registerFactories()
{
if (! app()->environment('production')) {
app(Factory::class)->load(__DIR__ . '/../$FACTORIES_PATH$');
}
}
/**
* Get the services provided by the provider.
*/

View File

@@ -91,6 +91,52 @@ class ApiTest extends TestCase
->assertJson(['data' => ['name' => $airline->name]]);
}
/**
* @throws Exception
*/
public function testPagination()
{
$size = \random_int(5, 10);
$this->user = factory(App\Models\User::class)->create([
'airline_id' => 0,
]);
factory(App\Models\Airline::class, $size)->create();
/*
* Page 0 and page 1 should return the same thing
*/
// Test pagination
$res = $this->get('/api/airlines?limit=1&page=0');
$this->assertTrue($res->isOk());
$body = $res->json('data');
$this->assertCount(1, $body);
$id_first = $body[0]['id'];
$res = $this->get('/api/airlines?limit=1&page=1');
$this->assertTrue($res->isOk());
$body = $res->json('data');
$id_second = $body[0]['id'];
$this->assertEquals($id_first, $id_second);
/*
* Page 2 should be different from page 1
*/
$res = $this->get('/api/airlines?limit=1&page=2');
$this->assertTrue($res->isOk());
$body = $res->json('data');
$id_third = $body[0]['id'];
$this->assertNotEquals($id_first, $id_third);
}
/**
* Make sure the airport data is returned
*/

View File

@@ -165,12 +165,12 @@ class FlightTest extends TestCase
'airline_id' => $this->user->airline_id,
]);
$res = $this->get('/api/flights');
$res = $this->get('/api/flights?limit=10');
$body = $res->json();
$this->assertEquals(2, $body['meta']['last_page']);
$res = $this->get('/api/flights?page=2');
$res = $this->get('/api/flights?page=2&limit=5');
$res->assertJsonCount(5, 'data');
}