2018-02-22 11:38:35 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
2020-05-23 23:43:29 +08:00
|
|
|
|
namespace Tests;
|
|
|
|
|
|
2019-07-18 01:36:16 +08:00
|
|
|
|
use App\Contracts\ImportExport;
|
|
|
|
|
use App\Models\Aircraft;
|
2020-05-23 23:43:29 +08:00
|
|
|
|
use App\Models\Airline;
|
2019-07-18 01:36:16 +08:00
|
|
|
|
use App\Models\Airport;
|
2020-02-09 02:29:34 +08:00
|
|
|
|
use App\Models\Enums\AircraftStatus;
|
2019-07-18 01:36:16 +08:00
|
|
|
|
use App\Models\Enums\Days;
|
|
|
|
|
use App\Models\Enums\ExpenseType;
|
2018-03-21 08:17:11 +08:00
|
|
|
|
use App\Models\Enums\FlightType;
|
2019-07-18 01:36:16 +08:00
|
|
|
|
use App\Models\Expense;
|
|
|
|
|
use App\Models\Fare;
|
|
|
|
|
use App\Models\Flight;
|
|
|
|
|
use App\Models\FlightFieldValue;
|
|
|
|
|
use App\Models\Subfleet;
|
|
|
|
|
use App\Services\ExportService;
|
2018-08-27 00:40:04 +08:00
|
|
|
|
use App\Services\FareService;
|
2019-07-18 01:36:16 +08:00
|
|
|
|
use App\Services\ImportExport\AircraftExporter;
|
|
|
|
|
use App\Services\ImportExport\AirportExporter;
|
|
|
|
|
use App\Services\ImportExport\FlightExporter;
|
|
|
|
|
use App\Services\ImportService;
|
2020-05-23 23:43:29 +08:00
|
|
|
|
use Illuminate\Support\Facades\Storage;
|
2019-09-17 01:08:26 +08:00
|
|
|
|
use Illuminate\Validation\ValidationException;
|
2018-02-22 11:38:35 +08:00
|
|
|
|
|
|
|
|
|
class ImporterTest extends TestCase
|
|
|
|
|
{
|
2018-08-27 00:40:04 +08:00
|
|
|
|
private $importBaseClass;
|
|
|
|
|
private $importSvc;
|
|
|
|
|
private $fareSvc;
|
2018-02-22 11:38:35 +08:00
|
|
|
|
|
2019-05-12 23:50:38 +08:00
|
|
|
|
public function setUp(): void
|
2018-02-22 11:38:35 +08:00
|
|
|
|
{
|
2018-03-21 08:17:11 +08:00
|
|
|
|
parent::setUp();
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$this->importBaseClass = new ImportExport();
|
|
|
|
|
$this->importSvc = app(ImportService::class);
|
|
|
|
|
$this->fareSvc = app(FareService::class);
|
2018-03-31 10:19:48 +08:00
|
|
|
|
|
|
|
|
|
Storage::fake('local');
|
2018-03-21 08:17:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add some of the basic data needed to properly import the flights.csv file
|
2018-08-27 00:40:04 +08:00
|
|
|
|
*
|
2018-03-21 08:17:11 +08:00
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
protected function insertFlightsScaffoldData()
|
|
|
|
|
{
|
|
|
|
|
$fare_svc = app(FareService::class);
|
|
|
|
|
|
|
|
|
|
$al = [
|
|
|
|
|
'icao' => 'VMS',
|
|
|
|
|
'name' => 'phpVMS Airlines',
|
|
|
|
|
];
|
|
|
|
|
|
2020-05-23 23:43:29 +08:00
|
|
|
|
$airline = factory(Airline::class)->create($al);
|
|
|
|
|
$subfleet = factory(Subfleet::class)->create(['type' => 'A32X']);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
|
2018-08-27 00:40:04 +08:00
|
|
|
|
// Add the economy class
|
2020-05-23 23:43:29 +08:00
|
|
|
|
$fare_economy = factory(Fare::class)->create(['code' => 'Y', 'capacity' => 150]);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
$fare_svc->setForSubfleet($subfleet, $fare_economy);
|
|
|
|
|
|
2020-05-23 23:43:29 +08:00
|
|
|
|
$fare_business = factory(Fare::class)->create(['code' => 'B', 'capacity' => 20]);
|
2018-03-23 06:48:57 +08:00
|
|
|
|
$fare_svc->setForSubfleet($subfleet, $fare_business);
|
2018-03-22 06:07:30 +08:00
|
|
|
|
|
2018-08-27 00:40:04 +08:00
|
|
|
|
// Add first class
|
2020-05-23 23:43:29 +08:00
|
|
|
|
$fare_first = factory(Fare::class)->create(['code' => 'F', 'capacity' => 10]);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
$fare_svc->setForSubfleet($subfleet, $fare_first);
|
|
|
|
|
|
2018-03-22 06:07:30 +08:00
|
|
|
|
return [$airline, $subfleet];
|
2018-02-22 11:38:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test the parsing of different field/column which can be used
|
|
|
|
|
* for specifying different field values
|
|
|
|
|
*/
|
2018-03-22 06:07:30 +08:00
|
|
|
|
public function testConvertStringtoObjects(): void
|
2018-02-22 11:38:35 +08:00
|
|
|
|
{
|
|
|
|
|
$tests = [
|
2018-03-31 07:53:43 +08:00
|
|
|
|
[
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'input' => '',
|
2018-03-31 07:53:43 +08:00
|
|
|
|
'expected' => [],
|
|
|
|
|
],
|
2018-02-22 11:42:47 +08:00
|
|
|
|
[
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'input' => 'gate',
|
|
|
|
|
'expected' => ['gate'],
|
2018-02-22 11:42:47 +08:00
|
|
|
|
],
|
2018-02-22 11:38:35 +08:00
|
|
|
|
[
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'input' => 'gate;cost index',
|
2018-02-22 11:38:35 +08:00
|
|
|
|
'expected' => [
|
|
|
|
|
'gate',
|
|
|
|
|
'cost index',
|
2018-08-27 00:40:04 +08:00
|
|
|
|
],
|
2018-02-22 11:38:35 +08:00
|
|
|
|
],
|
|
|
|
|
[
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'input' => 'gate=B32;cost index=100',
|
2018-02-22 11:38:35 +08:00
|
|
|
|
'expected' => [
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'gate' => 'B32',
|
|
|
|
|
'cost index' => '100',
|
|
|
|
|
],
|
2018-02-22 11:38:35 +08:00
|
|
|
|
],
|
|
|
|
|
[
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'input' => 'Y?price=200&cost=100; F?price=1200',
|
2018-02-22 11:38:35 +08:00
|
|
|
|
'expected' => [
|
|
|
|
|
'Y' => [
|
|
|
|
|
'price' => 200,
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'cost' => 100,
|
2018-02-22 11:38:35 +08:00
|
|
|
|
],
|
|
|
|
|
'F' => [
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'price' => 1200,
|
|
|
|
|
],
|
|
|
|
|
],
|
2018-02-22 11:38:35 +08:00
|
|
|
|
],
|
|
|
|
|
[
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'input' => 'Y?price&cost; F?price=1200',
|
2018-02-22 11:38:35 +08:00
|
|
|
|
'expected' => [
|
|
|
|
|
'Y' => [
|
|
|
|
|
'price',
|
|
|
|
|
'cost',
|
|
|
|
|
],
|
|
|
|
|
'F' => [
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'price' => 1200,
|
|
|
|
|
],
|
|
|
|
|
],
|
2018-03-21 08:17:11 +08:00
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'input' => 'Y; F?price=1200',
|
|
|
|
|
'expected' => [
|
2018-08-27 00:40:04 +08:00
|
|
|
|
0 => 'Y',
|
2018-03-21 08:17:11 +08:00
|
|
|
|
'F' => [
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'price' => 1200,
|
|
|
|
|
],
|
|
|
|
|
],
|
2018-03-21 08:17:11 +08:00
|
|
|
|
],
|
2018-03-22 06:07:30 +08:00
|
|
|
|
[
|
|
|
|
|
'input' => 'Y?;F?price=1200',
|
|
|
|
|
'expected' => [
|
2018-03-22 08:12:36 +08:00
|
|
|
|
'Y' => [],
|
2018-03-22 06:07:30 +08:00
|
|
|
|
'F' => [
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'price' => 1200,
|
|
|
|
|
],
|
|
|
|
|
],
|
2018-03-22 06:07:30 +08:00
|
|
|
|
],
|
2018-03-21 08:17:11 +08:00
|
|
|
|
[
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'input' => 'Departure Gate=4;Arrival Gate=C61',
|
2018-03-21 08:17:11 +08:00
|
|
|
|
'expected' => [
|
|
|
|
|
'Departure Gate' => '4',
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'Arrival Gate' => 'C61',
|
|
|
|
|
],
|
2018-03-21 08:17:11 +08:00
|
|
|
|
],
|
2021-07-23 03:56:03 +08:00
|
|
|
|
// Blank values omitted
|
|
|
|
|
[
|
|
|
|
|
'input' => 'gate; ',
|
|
|
|
|
'expected' => [
|
|
|
|
|
'gate',
|
|
|
|
|
],
|
|
|
|
|
],
|
2018-02-22 11:38:35 +08:00
|
|
|
|
];
|
|
|
|
|
|
2018-08-27 00:40:04 +08:00
|
|
|
|
foreach ($tests as $test) {
|
2018-03-21 08:17:11 +08:00
|
|
|
|
$parsed = $this->importBaseClass->parseMultiColumnValues($test['input']);
|
2018-03-22 06:07:30 +08:00
|
|
|
|
$this->assertEquals($test['expected'], $parsed);
|
2018-02-22 11:38:35 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-21 08:17:11 +08:00
|
|
|
|
|
2018-03-22 06:07:30 +08:00
|
|
|
|
/**
|
|
|
|
|
* Tests for converting the different object/array key values
|
|
|
|
|
* into the format that we use in CSV files
|
|
|
|
|
*/
|
|
|
|
|
public function testConvertObjectToString(): void
|
|
|
|
|
{
|
|
|
|
|
$tests = [
|
2018-03-31 07:53:43 +08:00
|
|
|
|
[
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'input' => '',
|
|
|
|
|
'expected' => '',
|
2018-03-31 07:53:43 +08:00
|
|
|
|
],
|
2018-03-22 06:07:30 +08:00
|
|
|
|
[
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'input' => ['gate'],
|
|
|
|
|
'expected' => 'gate',
|
2018-03-22 06:07:30 +08:00
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'input' => [
|
|
|
|
|
'gate',
|
|
|
|
|
'cost index',
|
|
|
|
|
],
|
|
|
|
|
'expected' => 'gate;cost index',
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'input' => [
|
|
|
|
|
'gate' => 'B32',
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'cost index' => '100',
|
2018-03-22 06:07:30 +08:00
|
|
|
|
],
|
|
|
|
|
'expected' => 'gate=B32;cost index=100',
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'input' => [
|
|
|
|
|
'Y' => [
|
|
|
|
|
'price' => 200,
|
|
|
|
|
'cost' => 100,
|
|
|
|
|
],
|
|
|
|
|
'F' => [
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'price' => 1200,
|
|
|
|
|
],
|
2018-03-22 06:07:30 +08:00
|
|
|
|
],
|
|
|
|
|
'expected' => 'Y?price=200&cost=100;F?price=1200',
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'input' => [
|
|
|
|
|
'Y' => [
|
|
|
|
|
'price',
|
|
|
|
|
'cost',
|
|
|
|
|
],
|
|
|
|
|
'F' => [
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'price' => 1200,
|
|
|
|
|
],
|
2018-03-22 06:07:30 +08:00
|
|
|
|
],
|
|
|
|
|
'expected' => 'Y?price&cost;F?price=1200',
|
|
|
|
|
],
|
|
|
|
|
[
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'input' => [
|
2018-03-22 06:07:30 +08:00
|
|
|
|
'Y' => [
|
|
|
|
|
'price',
|
|
|
|
|
'cost',
|
|
|
|
|
],
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'F' => [],
|
2018-03-22 06:07:30 +08:00
|
|
|
|
],
|
|
|
|
|
'expected' => 'Y?price&cost;F',
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'input' => [
|
|
|
|
|
0 => 'Y',
|
|
|
|
|
'F' => [
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'price' => 1200,
|
|
|
|
|
],
|
2018-03-22 06:07:30 +08:00
|
|
|
|
],
|
|
|
|
|
'expected' => 'Y;F?price=1200',
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'input' => [
|
|
|
|
|
'Departure Gate' => '4',
|
|
|
|
|
'Arrival Gate' => 'C61',
|
|
|
|
|
],
|
|
|
|
|
'expected' => 'Departure Gate=4;Arrival Gate=C61',
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
foreach ($tests as $test) {
|
|
|
|
|
$parsed = $this->importBaseClass->objectToMultiString($test['input']);
|
|
|
|
|
$this->assertEquals($test['expected'], $parsed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-31 09:21:18 +08:00
|
|
|
|
/**
|
|
|
|
|
* Test exporting all the flights to a file
|
2018-08-27 02:51:47 +08:00
|
|
|
|
*
|
2019-07-18 01:40:56 +08:00
|
|
|
|
* @throws \Illuminate\Validation\ValidationException
|
2018-03-31 09:21:18 +08:00
|
|
|
|
*/
|
|
|
|
|
public function testAircraftExporter(): void
|
|
|
|
|
{
|
2020-05-23 23:43:29 +08:00
|
|
|
|
$aircraft = factory(Aircraft::class)->create();
|
2018-03-31 10:19:48 +08:00
|
|
|
|
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$exporter = new AircraftExporter();
|
2018-03-31 09:21:18 +08:00
|
|
|
|
$exported = $exporter->export($aircraft);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($aircraft->iata, $exported['iata']);
|
|
|
|
|
$this->assertEquals($aircraft->icao, $exported['icao']);
|
|
|
|
|
$this->assertEquals($aircraft->name, $exported['name']);
|
|
|
|
|
$this->assertEquals($aircraft->zfw, $exported['zfw']);
|
|
|
|
|
$this->assertEquals($aircraft->subfleet->type, $exported['subfleet']);
|
2018-03-31 10:19:48 +08:00
|
|
|
|
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$importer = app(ImportService::class);
|
|
|
|
|
$exporter = app(ExportService::class);
|
2018-03-31 10:19:48 +08:00
|
|
|
|
$file = $exporter->exportAircraft(collect([$aircraft]));
|
|
|
|
|
$status = $importer->importAircraft($file);
|
|
|
|
|
$this->assertCount(1, $status['success']);
|
|
|
|
|
$this->assertCount(0, $status['errors']);
|
2018-03-31 09:21:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test exporting all the flights to a file
|
|
|
|
|
*/
|
|
|
|
|
public function testAirportExporter(): void
|
|
|
|
|
{
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$airport_name = 'Adolfo Suárez Madrid–Barajas Airport';
|
|
|
|
|
|
2020-05-23 23:43:29 +08:00
|
|
|
|
$airport = factory(Airport::class)->create([
|
2019-07-18 01:36:16 +08:00
|
|
|
|
'name' => $airport_name,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$exporter = new AirportExporter();
|
2018-03-31 09:21:18 +08:00
|
|
|
|
$exported = $exporter->export($airport);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($airport->iata, $exported['iata']);
|
|
|
|
|
$this->assertEquals($airport->icao, $exported['icao']);
|
|
|
|
|
$this->assertEquals($airport->name, $exported['name']);
|
2018-03-31 10:19:48 +08:00
|
|
|
|
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$importer = app(ImportService::class);
|
|
|
|
|
$exporter = app(ExportService::class);
|
2018-03-31 10:25:54 +08:00
|
|
|
|
$file = $exporter->exportAirports(collect([$airport]));
|
|
|
|
|
$status = $importer->importAirports($file);
|
2019-07-18 01:36:16 +08:00
|
|
|
|
|
2018-03-31 10:19:48 +08:00
|
|
|
|
$this->assertCount(1, $status['success']);
|
|
|
|
|
$this->assertCount(0, $status['errors']);
|
2018-03-31 09:21:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-22 06:07:30 +08:00
|
|
|
|
/**
|
|
|
|
|
* Test exporting all the flights to a file
|
|
|
|
|
*/
|
|
|
|
|
public function testFlightExporter(): void
|
|
|
|
|
{
|
|
|
|
|
$fareSvc = app(FareService::class);
|
|
|
|
|
|
|
|
|
|
[$airline, $subfleet] = $this->insertFlightsScaffoldData();
|
2020-05-23 23:43:29 +08:00
|
|
|
|
$subfleet2 = factory(Subfleet::class)->create(['type' => 'B74X']);
|
2018-03-22 06:07:30 +08:00
|
|
|
|
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$fareY = Fare::where('code', 'Y')->first();
|
|
|
|
|
$fareF = Fare::where('code', 'F')->first();
|
2018-03-22 06:07:30 +08:00
|
|
|
|
|
2020-05-23 23:43:29 +08:00
|
|
|
|
$flight = factory(Flight::class)->create([
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'airline_id' => $airline->id,
|
2018-03-31 07:08:03 +08:00
|
|
|
|
'flight_type' => 'J',
|
2019-07-18 01:36:16 +08:00
|
|
|
|
'days' => Days::getDaysMask([
|
|
|
|
|
Days::TUESDAY,
|
|
|
|
|
Days::SUNDAY,
|
2018-03-23 10:21:35 +08:00
|
|
|
|
]),
|
2018-03-22 06:07:30 +08:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$flight->subfleets()->syncWithoutDetaching([$subfleet->id, $subfleet2->id]);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
$fareSvc->setForFlight($flight, $fareY, ['capacity' => '100']);
|
|
|
|
|
$fareSvc->setForFlight($flight, $fareF);
|
|
|
|
|
|
|
|
|
|
// Add some custom fields
|
2019-07-18 01:36:16 +08:00
|
|
|
|
FlightFieldValue::create([
|
2018-03-22 06:07:30 +08:00
|
|
|
|
'flight_id' => $flight->id,
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'name' => 'Departure Gate',
|
|
|
|
|
'value' => '4',
|
2018-03-22 06:07:30 +08:00
|
|
|
|
]);
|
|
|
|
|
|
2019-07-18 01:36:16 +08:00
|
|
|
|
FlightFieldValue::create([
|
2018-03-22 06:07:30 +08:00
|
|
|
|
'flight_id' => $flight->id,
|
|
|
|
|
'name' => 'Arrival Gate',
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'value' => 'C41',
|
2018-03-22 06:07:30 +08:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// Test the conversion
|
|
|
|
|
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$exporter = new FlightExporter();
|
2018-03-22 06:07:30 +08:00
|
|
|
|
$exported = $exporter->export($flight);
|
|
|
|
|
|
2018-03-23 10:21:35 +08:00
|
|
|
|
$this->assertEquals('27', $exported['days']);
|
2018-03-22 06:07:30 +08:00
|
|
|
|
$this->assertEquals('VMS', $exported['airline']);
|
2018-03-31 09:57:30 +08:00
|
|
|
|
$this->assertEquals($flight->flight_time, $exported['flight_time']);
|
2018-03-31 07:08:03 +08:00
|
|
|
|
$this->assertEquals('J', $exported['flight_type']);
|
2018-03-22 06:07:30 +08:00
|
|
|
|
$this->assertEquals('A32X;B74X', $exported['subfleets']);
|
|
|
|
|
$this->assertEquals('Y?capacity=100;F', $exported['fares']);
|
|
|
|
|
$this->assertEquals('Departure Gate=4;Arrival Gate=C41', $exported['fields']);
|
2018-03-31 10:19:48 +08:00
|
|
|
|
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$importer = app(ImportService::class);
|
|
|
|
|
$exporter = app(ExportService::class);
|
2018-03-31 10:19:48 +08:00
|
|
|
|
$file = $exporter->exportFlights(collect([$flight]));
|
|
|
|
|
$status = $importer->importFlights($file);
|
|
|
|
|
$this->assertCount(1, $status['success']);
|
|
|
|
|
$this->assertCount(0, $status['errors']);
|
2018-03-22 06:07:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-23 06:17:37 +08:00
|
|
|
|
/**
|
|
|
|
|
* Try importing the aicraft in the airports. Should fail
|
|
|
|
|
*/
|
|
|
|
|
public function testInvalidFileImport(): void
|
|
|
|
|
{
|
2019-09-17 01:08:26 +08:00
|
|
|
|
$this->expectException(ValidationException::class);
|
2018-03-23 06:17:37 +08:00
|
|
|
|
$file_path = base_path('tests/data/aircraft.csv');
|
|
|
|
|
$this->importSvc->importAirports($file_path);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-31 06:27:29 +08:00
|
|
|
|
/**
|
|
|
|
|
* Try importing the aicraft in the airports. Should fail because of
|
|
|
|
|
* empty/invalid rows
|
|
|
|
|
*/
|
|
|
|
|
public function testEmptyCols(): void
|
|
|
|
|
{
|
|
|
|
|
$file_path = base_path('tests/data/expenses_empty_rows.csv');
|
|
|
|
|
$status = $this->importSvc->importExpenses($file_path);
|
|
|
|
|
$this->assertCount(8, $status['success']);
|
|
|
|
|
$this->assertCount(0, $status['errors']);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-23 06:17:37 +08:00
|
|
|
|
/**
|
|
|
|
|
* Test the importing of expenses
|
2018-08-27 00:40:04 +08:00
|
|
|
|
*
|
2019-07-18 01:40:56 +08:00
|
|
|
|
* @throws \Illuminate\Validation\ValidationException
|
2018-03-23 06:17:37 +08:00
|
|
|
|
*/
|
|
|
|
|
public function testExpenseImporter(): void
|
|
|
|
|
{
|
2020-05-23 23:43:29 +08:00
|
|
|
|
$airline = factory(Airline::class)->create(['icao' => 'VMS']);
|
|
|
|
|
$subfleet = factory(Subfleet::class)->create(['type' => '744-3X-RB211']);
|
|
|
|
|
$aircraft = factory(Aircraft::class)->create([
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'subfleet_id' => $subfleet->id,
|
2018-03-23 06:17:37 +08:00
|
|
|
|
'registration' => '001Z',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$file_path = base_path('tests/data/expenses.csv');
|
2018-03-31 06:27:29 +08:00
|
|
|
|
$status = $this->importSvc->importExpenses($file_path);
|
|
|
|
|
|
|
|
|
|
$this->assertCount(8, $status['success']);
|
|
|
|
|
$this->assertCount(0, $status['errors']);
|
2018-03-23 06:17:37 +08:00
|
|
|
|
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$expenses = Expense::all();
|
2018-03-23 06:17:37 +08:00
|
|
|
|
|
|
|
|
|
$on_airline = $expenses->where('name', 'Per-Flight (multiplier, on airline)')->first();
|
|
|
|
|
$this->assertEquals(200, $on_airline->amount);
|
|
|
|
|
$this->assertEquals($airline->id, $on_airline->airline_id);
|
|
|
|
|
|
|
|
|
|
$pf = $expenses->where('name', 'Per-Flight (no muliplier)')->first();
|
|
|
|
|
$this->assertEquals(100, $pf->amount);
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$this->assertEquals(ExpenseType::FLIGHT, $pf->type);
|
2018-03-23 06:17:37 +08:00
|
|
|
|
|
|
|
|
|
$catering = $expenses->where('name', 'Catering Staff')->first();
|
|
|
|
|
$this->assertEquals(1000, $catering->amount);
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$this->assertEquals(ExpenseType::DAILY, $catering->type);
|
|
|
|
|
$this->assertEquals(Subfleet::class, $catering->ref_model);
|
2018-04-02 03:32:01 +08:00
|
|
|
|
$this->assertEquals($subfleet->id, $catering->ref_model_id);
|
2018-03-23 06:17:37 +08:00
|
|
|
|
|
|
|
|
|
$mnt = $expenses->where('name', 'Maintenance')->first();
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$this->assertEquals(Aircraft::class, $mnt->ref_model);
|
2018-04-02 03:32:01 +08:00
|
|
|
|
$this->assertEquals($aircraft->id, $mnt->ref_model_id);
|
2018-03-23 06:17:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-23 06:48:57 +08:00
|
|
|
|
/**
|
2019-07-18 01:40:56 +08:00
|
|
|
|
* @throws \Illuminate\Validation\ValidationException
|
2018-03-23 06:48:57 +08:00
|
|
|
|
*/
|
|
|
|
|
public function testFareImporter(): void
|
|
|
|
|
{
|
|
|
|
|
$file_path = base_path('tests/data/fares.csv');
|
2018-03-31 06:27:29 +08:00
|
|
|
|
$status = $this->importSvc->importFares($file_path);
|
|
|
|
|
|
|
|
|
|
$this->assertCount(3, $status['success']);
|
|
|
|
|
$this->assertCount(0, $status['errors']);
|
2018-03-23 06:48:57 +08:00
|
|
|
|
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$fares = Fare::all();
|
2018-03-23 06:48:57 +08:00
|
|
|
|
|
|
|
|
|
$y_class = $fares->where('code', 'Y')->first();
|
|
|
|
|
$this->assertEquals('Economy', $y_class->name);
|
|
|
|
|
$this->assertEquals(100, $y_class->price);
|
|
|
|
|
$this->assertEquals(0, $y_class->cost);
|
|
|
|
|
$this->assertEquals(200, $y_class->capacity);
|
|
|
|
|
$this->assertEquals(true, $y_class->active);
|
|
|
|
|
$this->assertEquals('This is the economy class', $y_class->notes);
|
|
|
|
|
|
|
|
|
|
$b_class = $fares->where('code', 'B')->first();
|
|
|
|
|
$this->assertEquals('Business', $b_class->name);
|
|
|
|
|
$this->assertEquals(500, $b_class->price);
|
|
|
|
|
$this->assertEquals(250, $b_class->cost);
|
|
|
|
|
$this->assertEquals(10, $b_class->capacity);
|
|
|
|
|
$this->assertEquals('This is business class', $b_class->notes);
|
|
|
|
|
$this->assertEquals(false, $b_class->active);
|
|
|
|
|
|
|
|
|
|
$f_class = $fares->where('code', 'F')->first();
|
|
|
|
|
$this->assertEquals('First-Class', $f_class->name);
|
|
|
|
|
$this->assertEquals(800, $f_class->price);
|
|
|
|
|
$this->assertEquals(350, $f_class->cost);
|
|
|
|
|
$this->assertEquals(5, $f_class->capacity);
|
|
|
|
|
$this->assertEquals('', $f_class->notes);
|
|
|
|
|
$this->assertEquals(true, $f_class->active);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-21 08:17:11 +08:00
|
|
|
|
/**
|
|
|
|
|
* Test the flight importer
|
2018-08-27 00:40:04 +08:00
|
|
|
|
*
|
2019-07-18 01:40:56 +08:00
|
|
|
|
* @throws \Illuminate\Validation\ValidationException
|
2018-03-21 08:17:11 +08:00
|
|
|
|
*/
|
|
|
|
|
public function testFlightImporter(): void
|
|
|
|
|
{
|
2018-03-22 06:07:30 +08:00
|
|
|
|
[$airline, $subfleet] = $this->insertFlightsScaffoldData();
|
2018-03-21 08:17:11 +08:00
|
|
|
|
|
|
|
|
|
$file_path = base_path('tests/data/flights.csv');
|
2018-03-31 06:27:29 +08:00
|
|
|
|
$status = $this->importSvc->importFlights($file_path);
|
|
|
|
|
|
2021-03-23 20:50:19 +08:00
|
|
|
|
$this->assertCount(3, $status['success']);
|
2018-03-31 06:27:29 +08:00
|
|
|
|
$this->assertCount(1, $status['errors']);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
|
|
|
|
|
// See if it imported
|
2020-10-28 06:46:15 +08:00
|
|
|
|
/** @var Flight $flight */
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$flight = Flight::where([
|
2018-03-21 08:17:11 +08:00
|
|
|
|
'airline_id' => $airline->id,
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'flight_number' => '1972',
|
2018-03-21 08:17:11 +08:00
|
|
|
|
])->first();
|
|
|
|
|
|
|
|
|
|
$this->assertNotNull($flight);
|
|
|
|
|
|
|
|
|
|
// Check the flight itself
|
|
|
|
|
$this->assertEquals('KAUS', $flight->dpt_airport_id);
|
|
|
|
|
$this->assertEquals('KJFK', $flight->arr_airport_id);
|
|
|
|
|
$this->assertEquals('0810 CST', $flight->dpt_time);
|
|
|
|
|
$this->assertEquals('1235 EST', $flight->arr_time);
|
|
|
|
|
$this->assertEquals('350', $flight->level);
|
2019-07-23 20:41:20 +08:00
|
|
|
|
$this->assertEquals(1477, $flight->distance);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
$this->assertEquals('207', $flight->flight_time);
|
2018-03-30 00:34:36 +08:00
|
|
|
|
$this->assertEquals(FlightType::SCHED_PAX, $flight->flight_type);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
$this->assertEquals('ILEXY2 ZENZI LFK ELD J29 MEM Q29 JHW J70 STENT J70 MAGIO J70 LVZ LENDY6', $flight->route);
|
|
|
|
|
$this->assertEquals('Just a flight', $flight->notes);
|
|
|
|
|
$this->assertEquals(true, $flight->active);
|
|
|
|
|
|
2018-08-27 00:40:04 +08:00
|
|
|
|
// Test that the days were set properly
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$this->assertTrue($flight->on_day(Days::MONDAY));
|
|
|
|
|
$this->assertTrue($flight->on_day(Days::FRIDAY));
|
|
|
|
|
$this->assertFalse($flight->on_day(Days::TUESDAY));
|
2018-03-23 10:21:35 +08:00
|
|
|
|
|
2018-03-21 08:17:11 +08:00
|
|
|
|
// Check the custom fields entered
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$fields = FlightFieldValue::where([
|
2018-03-21 08:17:11 +08:00
|
|
|
|
'flight_id' => $flight->id,
|
|
|
|
|
])->get();
|
|
|
|
|
|
|
|
|
|
$this->assertCount(2, $fields);
|
|
|
|
|
$dep_gate = $fields->where('name', 'Departure Gate')->first();
|
|
|
|
|
$this->assertEquals('4', $dep_gate['value']);
|
|
|
|
|
|
|
|
|
|
$dep_gate = $fields->where('name', 'Arrival Gate')->first();
|
|
|
|
|
$this->assertEquals('C41', $dep_gate['value']);
|
|
|
|
|
|
|
|
|
|
// Check the fare class
|
2020-10-28 06:46:15 +08:00
|
|
|
|
$fares = $this->fareSvc->getFareWithOverrides(null, $flight->fares);
|
2018-03-22 06:07:30 +08:00
|
|
|
|
$this->assertCount(3, $fares);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
|
|
|
|
|
$first = $fares->where('code', 'Y')->first();
|
|
|
|
|
$this->assertEquals(300, $first->price);
|
|
|
|
|
$this->assertEquals(100, $first->cost);
|
|
|
|
|
$this->assertEquals(130, $first->capacity);
|
|
|
|
|
|
|
|
|
|
$first = $fares->where('code', 'F')->first();
|
|
|
|
|
$this->assertEquals(600, $first->price);
|
|
|
|
|
$this->assertEquals(400, $first->cost);
|
|
|
|
|
$this->assertEquals(10, $first->capacity);
|
|
|
|
|
|
|
|
|
|
// Check the subfleets
|
|
|
|
|
$subfleets = $flight->subfleets;
|
|
|
|
|
$this->assertCount(1, $subfleets);
|
2021-03-23 20:50:19 +08:00
|
|
|
|
$this->assertNotEquals('A32X', $subfleets[0]->name);
|
|
|
|
|
|
|
|
|
|
$flight = Flight::where([
|
|
|
|
|
'airline_id' => $airline->id,
|
|
|
|
|
'flight_number' => '999',
|
|
|
|
|
])->first();
|
|
|
|
|
$subfleets = $flight->subfleets;
|
|
|
|
|
$this->assertCount(2, $subfleets);
|
|
|
|
|
$this->assertEquals('B737', $subfleets[1]->type);
|
|
|
|
|
$this->assertEquals('B737', $subfleets[1]->name);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-31 07:53:43 +08:00
|
|
|
|
/**
|
|
|
|
|
* Test the flight importer
|
2018-08-27 00:40:04 +08:00
|
|
|
|
*
|
2019-07-18 01:40:56 +08:00
|
|
|
|
* @throws \Illuminate\Validation\ValidationException
|
2018-03-31 07:53:43 +08:00
|
|
|
|
*/
|
|
|
|
|
public function testFlightImporterEmptyCustomFields(): void
|
|
|
|
|
{
|
|
|
|
|
[$airline, $subfleet] = $this->insertFlightsScaffoldData();
|
|
|
|
|
|
|
|
|
|
$file_path = base_path('tests/data/flights_empty_fields.csv');
|
|
|
|
|
$status = $this->importSvc->importFlights($file_path);
|
|
|
|
|
|
|
|
|
|
$this->assertCount(1, $status['success']);
|
|
|
|
|
$this->assertCount(0, $status['errors']);
|
|
|
|
|
|
|
|
|
|
// See if it imported
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$flight = Flight::where([
|
2018-03-31 07:53:43 +08:00
|
|
|
|
'airline_id' => $airline->id,
|
2018-08-27 00:40:04 +08:00
|
|
|
|
'flight_number' => '1972',
|
2018-03-31 07:53:43 +08:00
|
|
|
|
])->first();
|
|
|
|
|
|
|
|
|
|
$this->assertNotNull($flight);
|
|
|
|
|
|
|
|
|
|
// Check the custom fields entered
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$fields = FlightFieldValue::where([
|
2018-03-31 07:53:43 +08:00
|
|
|
|
'flight_id' => $flight->id,
|
|
|
|
|
])->get();
|
|
|
|
|
|
|
|
|
|
$this->assertCount(0, $fields);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-21 08:17:11 +08:00
|
|
|
|
/**
|
2019-07-18 01:40:56 +08:00
|
|
|
|
* @throws \Illuminate\Validation\ValidationException
|
2018-03-21 08:17:11 +08:00
|
|
|
|
*/
|
2018-03-22 06:07:30 +08:00
|
|
|
|
public function testAircraftImporter(): void
|
2018-03-21 08:17:11 +08:00
|
|
|
|
{
|
2020-05-23 23:43:29 +08:00
|
|
|
|
factory(Airline::class)->create();
|
|
|
|
|
// $subfleet = factory(\App\Models\Subfleet::class)->create(['type' => 'A32X']);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
|
|
|
|
|
$file_path = base_path('tests/data/aircraft.csv');
|
2018-03-31 06:27:29 +08:00
|
|
|
|
$status = $this->importSvc->importAircraft($file_path);
|
|
|
|
|
|
|
|
|
|
$this->assertCount(1, $status['success']);
|
|
|
|
|
$this->assertCount(1, $status['errors']);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
|
|
|
|
|
// See if it imported
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$aircraft = Aircraft::where([
|
2018-03-21 08:17:11 +08:00
|
|
|
|
'registration' => 'N309US',
|
|
|
|
|
])->first();
|
|
|
|
|
|
|
|
|
|
$this->assertNotNull($aircraft);
|
2018-03-31 10:56:55 +08:00
|
|
|
|
$this->assertNotNull($aircraft->hex_code);
|
2020-02-09 02:29:34 +08:00
|
|
|
|
$this->assertNotNull($aircraft->subfleet);
|
|
|
|
|
$this->assertNotNull($aircraft->subfleet->airline);
|
|
|
|
|
$this->assertEquals('A32X', $aircraft->subfleet->type);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
$this->assertEquals('A320-211', $aircraft->name);
|
|
|
|
|
$this->assertEquals('N309US', $aircraft->registration);
|
2018-03-31 10:45:11 +08:00
|
|
|
|
$this->assertEquals(null, $aircraft->zfw);
|
2020-02-09 02:29:34 +08:00
|
|
|
|
$this->assertEquals(AircraftStatus::ACTIVE, $aircraft->status);
|
|
|
|
|
|
|
|
|
|
// Now try importing the updated file, the status for the aircraft should change
|
|
|
|
|
// to being stored
|
|
|
|
|
|
|
|
|
|
$file_path = base_path('tests/data/aircraft-update.csv');
|
|
|
|
|
$status = $this->importSvc->importAircraft($file_path);
|
|
|
|
|
$this->assertCount(1, $status['success']);
|
|
|
|
|
|
|
|
|
|
$aircraft = Aircraft::where([
|
|
|
|
|
'registration' => 'N309US',
|
|
|
|
|
])->first();
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(AircraftStatus::STORED, $aircraft->status);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-18 01:40:56 +08:00
|
|
|
|
* @throws \Illuminate\Validation\ValidationException
|
2018-03-21 08:17:11 +08:00
|
|
|
|
*/
|
2018-03-22 06:07:30 +08:00
|
|
|
|
public function testAirportImporter(): void
|
2018-03-21 08:17:11 +08:00
|
|
|
|
{
|
|
|
|
|
$file_path = base_path('tests/data/airports.csv');
|
2018-03-31 06:27:29 +08:00
|
|
|
|
$status = $this->importSvc->importAirports($file_path);
|
|
|
|
|
|
2018-05-06 23:21:43 +08:00
|
|
|
|
$this->assertCount(2, $status['success']);
|
2018-03-31 06:27:29 +08:00
|
|
|
|
$this->assertCount(1, $status['errors']);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
|
|
|
|
|
// See if it imported
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$airport = Airport::where([
|
2018-03-21 08:17:11 +08:00
|
|
|
|
'id' => 'KAUS',
|
|
|
|
|
])->first();
|
|
|
|
|
|
|
|
|
|
$this->assertNotNull($airport);
|
|
|
|
|
$this->assertEquals('KAUS', $airport->id);
|
|
|
|
|
$this->assertEquals('AUS', $airport->iata);
|
|
|
|
|
$this->assertEquals('KAUS', $airport->icao);
|
2018-03-31 10:51:13 +08:00
|
|
|
|
$this->assertEquals('Austin-Bergstrom', $airport->name);
|
|
|
|
|
$this->assertEquals('Austin, Texas, USA', $airport->location);
|
|
|
|
|
$this->assertEquals('United States', $airport->country);
|
|
|
|
|
$this->assertEquals('America/Chicago', $airport->timezone);
|
|
|
|
|
$this->assertEquals(true, $airport->hub);
|
|
|
|
|
$this->assertEquals('30.1945', $airport->lat);
|
|
|
|
|
$this->assertEquals('-97.6699', $airport->lon);
|
2020-10-21 03:25:13 +08:00
|
|
|
|
$this->assertEquals(0.0, $airport->ground_handling_cost);
|
|
|
|
|
$this->assertEquals(setting('airports.default_jet_a_fuel_cost'), $airport->fuel_jeta_cost);
|
2018-05-06 23:21:43 +08:00
|
|
|
|
|
|
|
|
|
// See if it imported
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$airport = Airport::where([
|
2018-05-06 23:21:43 +08:00
|
|
|
|
'id' => 'KSFO',
|
|
|
|
|
])->first();
|
|
|
|
|
|
|
|
|
|
$this->assertNotNull($airport);
|
|
|
|
|
$this->assertEquals(true, $airport->hub);
|
2020-10-21 03:25:13 +08:00
|
|
|
|
$this->assertEquals(0.9, $airport->fuel_jeta_cost);
|
|
|
|
|
$this->assertEquals(setting('airports.default_ground_handling_cost'), $airport->ground_handling_cost);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test importing the subfleets
|
2018-08-27 00:40:04 +08:00
|
|
|
|
*
|
2019-07-18 01:40:56 +08:00
|
|
|
|
* @throws \Illuminate\Validation\ValidationException
|
2018-03-21 08:17:11 +08:00
|
|
|
|
*/
|
|
|
|
|
public function testSubfleetImporter(): void
|
|
|
|
|
{
|
2020-05-23 23:43:29 +08:00
|
|
|
|
$fare_economy = factory(Fare::class)->create(['code' => 'Y', 'capacity' => 150]);
|
|
|
|
|
$fare_business = factory(Fare::class)->create(['code' => 'B', 'capacity' => 20]);
|
|
|
|
|
$airline = factory(Airline::class)->create(['icao' => 'VMS']);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
|
|
|
|
|
$file_path = base_path('tests/data/subfleets.csv');
|
2018-03-31 06:27:29 +08:00
|
|
|
|
$status = $this->importSvc->importSubfleets($file_path);
|
|
|
|
|
|
|
|
|
|
$this->assertCount(1, $status['success']);
|
|
|
|
|
$this->assertCount(1, $status['errors']);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
|
|
|
|
|
// See if it imported
|
2019-07-18 01:36:16 +08:00
|
|
|
|
$subfleet = Subfleet::where([
|
2018-03-21 08:17:11 +08:00
|
|
|
|
'type' => 'A32X',
|
|
|
|
|
])->first();
|
|
|
|
|
|
|
|
|
|
$this->assertNotNull($subfleet);
|
|
|
|
|
$this->assertEquals($airline->id, $subfleet->id);
|
|
|
|
|
$this->assertEquals('A32X', $subfleet->type);
|
|
|
|
|
$this->assertEquals('Airbus A320', $subfleet->name);
|
2018-03-23 06:48:57 +08:00
|
|
|
|
|
2018-03-23 06:59:10 +08:00
|
|
|
|
// get the fares and check the pivot tables and the main tables
|
|
|
|
|
$fares = $subfleet->fares()->get();
|
2018-03-23 06:48:57 +08:00
|
|
|
|
|
|
|
|
|
$eco = $fares->where('code', 'Y')->first();
|
2018-03-23 06:59:10 +08:00
|
|
|
|
$this->assertEquals(null, $eco->pivot->price);
|
|
|
|
|
$this->assertEquals(null, $eco->pivot->capacity);
|
|
|
|
|
$this->assertEquals(null, $eco->pivot->cost);
|
|
|
|
|
|
2018-03-23 06:48:57 +08:00
|
|
|
|
$this->assertEquals($fare_economy->price, $eco->price);
|
2018-03-23 06:59:10 +08:00
|
|
|
|
$this->assertEquals($fare_economy->capacity, $eco->capacity);
|
2018-03-23 06:48:57 +08:00
|
|
|
|
$this->assertEquals($fare_economy->cost, $eco->cost);
|
|
|
|
|
|
|
|
|
|
$busi = $fares->where('code', 'B')->first();
|
2018-03-23 06:59:10 +08:00
|
|
|
|
$this->assertEquals($fare_business->price, $busi->price);
|
|
|
|
|
$this->assertEquals($fare_business->capacity, $busi->capacity);
|
2018-03-23 06:48:57 +08:00
|
|
|
|
$this->assertEquals($fare_business->cost, $busi->cost);
|
2018-03-23 06:59:10 +08:00
|
|
|
|
|
|
|
|
|
$this->assertEquals('500%', $busi->pivot->price);
|
|
|
|
|
$this->assertEquals(100, $busi->pivot->capacity);
|
|
|
|
|
$this->assertEquals(null, $busi->pivot->cost);
|
2018-03-21 08:17:11 +08:00
|
|
|
|
}
|
2019-07-18 01:36:16 +08:00
|
|
|
|
|
|
|
|
|
public function testAirportSpecialCharsImporter(): void
|
|
|
|
|
{
|
|
|
|
|
$file_path = base_path('tests/data/airports_special_chars.csv');
|
|
|
|
|
$status = $this->importSvc->importAirports($file_path);
|
|
|
|
|
|
|
|
|
|
// See if it imported
|
|
|
|
|
$airport = Airport::where([
|
|
|
|
|
'id' => 'LEMD',
|
|
|
|
|
])->first();
|
|
|
|
|
|
|
|
|
|
$this->assertNotNull($airport);
|
|
|
|
|
$this->assertEquals('Adolfo Suárez Madrid–Barajas Airport', $airport->name);
|
|
|
|
|
}
|
2018-02-22 11:38:35 +08:00
|
|
|
|
}
|