#21 PIREP accept/reject tests
This commit is contained in:
@@ -1,18 +1,64 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Pirep;
|
||||
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class PIREPTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExample()
|
||||
use WithoutMiddleware;
|
||||
|
||||
protected $pirepSvc;
|
||||
protected $SAMPLE_PIREP
|
||||
= [
|
||||
'user_id' => 1,
|
||||
'flight_id' => 1,
|
||||
'aircraft_id' => 1,
|
||||
'dpt_airport_id' => 1,
|
||||
'arr_airport_id' => 2,
|
||||
'flight_time' => 21600, # 6 hours
|
||||
'level' => 320,
|
||||
'source' => 0, # manual
|
||||
'notes' => 'just a pilot report',
|
||||
];
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
$this->addData('base');
|
||||
|
||||
$this->pirepSvc = app('App\Services\PIREPService');
|
||||
}
|
||||
|
||||
public function testAddPirep()
|
||||
{
|
||||
$pirep = new Pirep($this->SAMPLE_PIREP);
|
||||
$pirep->save();
|
||||
|
||||
$pirep = $this->pirepSvc->create($pirep, []);
|
||||
|
||||
/**
|
||||
* Check the initial status info
|
||||
*/
|
||||
$this->assertEquals($pirep->pilot->flights, 0);
|
||||
$this->assertEquals($pirep->status, VMSEnums::$pirep_status['PENDING']);
|
||||
|
||||
/**
|
||||
* Now set the PIREP state to ACCEPTED
|
||||
*/
|
||||
$this->pirepSvc->changeStatus($pirep, VMSEnums::$pirep_status['ACCEPTED']);
|
||||
$this->assertEquals(1, $pirep->pilot->flights);
|
||||
$this->assertEquals(21600, $pirep->pilot->flight_time);
|
||||
$this->assertEquals(1, $pirep->pilot->rank_id);
|
||||
|
||||
/**
|
||||
* Now go from ACCEPTED to REJECTED
|
||||
*/
|
||||
$this->pirepSvc->changeStatus($pirep, VMSEnums::$pirep_status['REJECTED']);
|
||||
$this->assertEquals(0, $pirep->pilot->flights);
|
||||
$this->assertEquals(0, $pirep->pilot->flight_time);
|
||||
$this->assertEquals(1, $pirep->pilot->rank_id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user