New subfleet not being attached to an airline on import #479 (#505)

* Fix subfleet not being attached to an airline on creation in import #479

* Call airline name with optional() around subfleet

* Minor cleanup
This commit is contained in:
Nabeel S
2020-01-16 14:23:23 -05:00
committed by GitHub
parent 6fcbd603ba
commit d03a77bd4b
3 changed files with 14 additions and 9 deletions

View File

@@ -564,7 +564,8 @@ class ImporterTest extends TestCase
*/
public function testAircraftImporter(): void
{
$subfleet = factory(App\Models\Subfleet::class)->create(['type' => 'A32X']);
factory(App\Models\Airline::class)->create();
// $subfleet = factory(App\Models\Subfleet::class)->create(['type' => 'A32X']);
$file_path = base_path('tests/data/aircraft.csv');
$status = $this->importSvc->importAircraft($file_path);
@@ -579,8 +580,9 @@ class ImporterTest extends TestCase
$this->assertNotNull($aircraft);
$this->assertNotNull($aircraft->hex_code);
$this->assertEquals($subfleet->id, $aircraft->id);
$this->assertEquals($subfleet->type, $aircraft->subfleet->type);
$this->assertNotNull($aircraft->subfleet);
$this->assertNotNull($aircraft->subfleet->airline);
$this->assertEquals('A32X', $aircraft->subfleet->type);
$this->assertEquals('A320-211', $aircraft->name);
$this->assertEquals('N309US', $aircraft->registration);
$this->assertEquals(null, $aircraft->zfw);