Skip to content

Commit

Permalink
Update testFareImporter
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurpar06 committed Mar 28, 2024
1 parent f222b03 commit d60accb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
15 changes: 14 additions & 1 deletion tests/ImporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Models\Enums\AircraftStatus;
use App\Models\Enums\Days;
use App\Models\Enums\ExpenseType;
use App\Models\Enums\FareType;
use App\Models\Enums\FlightType;
use App\Models\Expense;
use App\Models\Fare;
Expand Down Expand Up @@ -461,13 +462,14 @@ public function testFareImporter(): void
$file_path = base_path('tests/data/fares.csv');
$status = $this->importSvc->importFares($file_path);

$this->assertCount(3, $status['success']);
$this->assertCount(4, $status['success']);
$this->assertCount(0, $status['errors']);

$fares = Fare::all();

$y_class = $fares->firstWhere('code', 'Y');
$this->assertEquals('Economy', $y_class->name);
$this->assertEquals(FareType::PASSENGER, $y_class->type);
$this->assertEquals(100, $y_class->price);
$this->assertEquals(0, $y_class->cost);
$this->assertEquals(200, $y_class->capacity);
Expand All @@ -476,6 +478,7 @@ public function testFareImporter(): void

$b_class = $fares->firstWhere('code', 'B');
$this->assertEquals('Business', $b_class->name);
$this->assertEquals(FareType::PASSENGER, $b_class->type);
$this->assertEquals(500, $b_class->price);
$this->assertEquals(250, $b_class->cost);
$this->assertEquals(10, $b_class->capacity);
Expand All @@ -484,11 +487,21 @@ public function testFareImporter(): void

$f_class = $fares->firstWhere('code', 'F');
$this->assertEquals('First-Class', $f_class->name);
$this->assertEquals(FareType::PASSENGER, $f_class->type);
$this->assertEquals(800, $f_class->price);
$this->assertEquals(350, $f_class->cost);
$this->assertEquals(5, $f_class->capacity);
$this->assertEquals('', $f_class->notes);
$this->assertTrue($f_class->active);

$cargo = $fares->firstWhere('code', 'C');
$this->assertEquals('Cargo', $cargo->name);
$this->assertEquals(FareType::CARGO, $cargo->type);
$this->assertEquals(20, $cargo->price);
$this->assertEquals(0, $cargo->cost);
$this->assertEquals(10, $cargo->capacity);
$this->assertEquals('', $cargo->notes);
$this->assertTrue($cargo->active);
}

/**
Expand Down
9 changes: 5 additions & 4 deletions tests/data/fares.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
code,name,price,cost,capacity,notes,active
Y,Economy,100,0,200,This is the economy class,1
B,Business,500,250,10,"This is business class",0
F,First-Class,800,350,5,,1
code,name,type,price,cost,capacity,notes,active
Y,Economy,0,100,0,200,This is the economy class,1
B,Business,0,500,250,10,"This is business class",0
F,First-Class,0,800,350,5,,1
C,Cargo,1,20,0,10,,1

0 comments on commit d60accb

Please sign in to comment.