Add days of week to flights table; add to import/export for flights
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Enums\Days;
|
||||
use App\Models\Flight;
|
||||
use App\Models\User;
|
||||
use App\Models\Bid;
|
||||
@@ -118,6 +119,41 @@ class FlightTest extends TestCase
|
||||
$res->assertJsonCount(5, 'data');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the bitmasks that they work for setting the day of week and
|
||||
* then retrieving by searching on those
|
||||
*/
|
||||
public function testFindDaysOfWeek(): void
|
||||
{
|
||||
$this->user = factory(App\Models\User::class)->create();
|
||||
factory(App\Models\Flight::class, 20)->create([
|
||||
'airline_id' => $this->user->airline_id
|
||||
]);
|
||||
|
||||
$saved_flight = factory(App\Models\Flight::class)->create([
|
||||
'airline_id' => $this->user->airline_id,
|
||||
'days' => Days::getDaysMask([
|
||||
Days::SUNDAY,
|
||||
Days::THURSDAY
|
||||
])
|
||||
]);
|
||||
|
||||
$flight = Flight::findByDays([Days::SUNDAY])->first();
|
||||
$this->assertTrue($flight->on_day(Days::SUNDAY));
|
||||
$this->assertTrue($flight->on_day(Days::THURSDAY));
|
||||
$this->assertFalse($flight->on_day(Days::MONDAY));
|
||||
$this->assertEquals($saved_flight->id, $flight->id);
|
||||
|
||||
$flight = Flight::findByDays([Days::SUNDAY, Days::THURSDAY])->first();
|
||||
$this->assertEquals($saved_flight->id, $flight->id);
|
||||
|
||||
$flight = Flight::findByDays([Days::WEDNESDAY, Days::THURSDAY])->first();
|
||||
$this->assertNull($flight);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testFlightSearchApi()
|
||||
{
|
||||
$this->user = factory(App\Models\User::class)->create();
|
||||
|
||||
@@ -230,6 +230,10 @@ class ImporterTest extends TestCase
|
||||
|
||||
$flight = factory(App\Models\Flight::class)->create([
|
||||
'airline_id' => $airline->id,
|
||||
'days' => \App\Models\Enums\Days::getDaysMask([
|
||||
\App\Models\Enums\Days::TUESDAY,
|
||||
\App\Models\Enums\Days::SUNDAY,
|
||||
]),
|
||||
]);
|
||||
|
||||
$flight->subfleets()->syncWithoutDetaching([$subfleet->id, $subfleet2->id]);
|
||||
@@ -256,6 +260,7 @@ class ImporterTest extends TestCase
|
||||
$exporter = new \App\Services\ImportExport\FlightExporter();
|
||||
$exported = $exporter->export($flight);
|
||||
|
||||
$this->assertEquals('27', $exported['days']);
|
||||
$this->assertEquals('VMS', $exported['airline']);
|
||||
$this->assertEquals('A32X;B74X', $exported['subfleets']);
|
||||
$this->assertEquals('Y?capacity=100;F', $exported['fares']);
|
||||
@@ -376,6 +381,11 @@ class ImporterTest extends TestCase
|
||||
$this->assertEquals('Just a flight', $flight->notes);
|
||||
$this->assertEquals(true, $flight->active);
|
||||
|
||||
# Test that the days were set properly
|
||||
$this->assertTrue($flight->on_day(\App\Models\Enums\Days::MONDAY));
|
||||
$this->assertTrue($flight->on_day(\App\Models\Enums\Days::FRIDAY));
|
||||
$this->assertFalse($flight->on_day(\App\Models\Enums\Days::TUESDAY));
|
||||
|
||||
// Check the custom fields entered
|
||||
$fields = \App\Models\FlightFieldValue::where([
|
||||
'flight_id' => $flight->id,
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
airline,flight_number,route_code,route_leg,dpt_airport,arr_airport,alt_airport,days,dpt_time,arr_time,level,distance,flight_time,flight_type,route,notes,active,subfleets,fares,fields
|
||||
VMS,1972,,,KAUS,KJFK,KLGA,,0810 CST,1235 EST,350,1477,207,P,ILEXY2 ZENZI LFK ELD J29 MEM Q29 JHW J70 STENT J70 MAGIO J70 LVZ LENDY6,"Just a flight",1,A32X,Y?price=300&cost=100&capacity=130;F?price=600&cost=400;B?,Departure Gate=4;Arrival Gate=C41
|
||||
VMS,1972,,,KAUS,KJFK,KLGA,15,0810 CST,1235 EST,350,1477,207,P,ILEXY2 ZENZI LFK ELD J29 MEM Q29 JHW J70 STENT J70 MAGIO J70 LVZ LENDY6,"Just a flight",1,A32X,Y?price=300&cost=100&capacity=130;F?price=600&cost=400;B?,Departure Gate=4;Arrival Gate=C41
|
||||
|
||||
|
Reference in New Issue
Block a user