Tests for the CSV import fix

#1007
This commit is contained in:
Nabeel Shahzad
2021-01-25 16:49:32 -05:00
parent 5821067231
commit 3f92191126
5 changed files with 27 additions and 7 deletions

View File

@@ -467,6 +467,11 @@ class ImporterTest extends TestCase
*/
public function testFlightImporter(): void
{
$this->updateSetting('general.auto_airport_lookup', false);
factory(Airport::class)->create(['icao' => 'KAUS']);
factory(Airport::class)->create(['icao' => 'KJFK']);
[$airline, $subfleet] = $this->insertFlightsScaffoldData();
$file_path = base_path('tests/data/flights.csv');
@@ -531,6 +536,19 @@ class ImporterTest extends TestCase
// Check the subfleets
$subfleets = $flight->subfleets;
$this->assertCount(1, $subfleets);
// Reimport, see that data updates
$file_path = base_path('tests/data/flights-update.csv');
$status = $this->importSvc->importFlights($file_path);
$flight = Flight::where([
'airline_id' => $airline->id,
'flight_number' => '1972',
])->first();
$this->assertCount(1, $status['success']);
$this->assertEquals('12:00 CST', $flight->dpt_time);
$this->assertEquals('18:35 EST', $flight->arr_time);
}
/**