#21 PIREP accept/reject tests
This commit is contained in:
parent
fecadcfb41
commit
c310bffed9
6
.idea/runConfigurations/PIREPTest.xml
Normal file
6
.idea/runConfigurations/PIREPTest.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="PIREPTest" type="PHPUnitRunConfigurationType" factoryName="PHPUnit" singleton="true">
|
||||
<TestRunner class="PIREPTest" configuration_file="$PROJECT_DIR$/phpunit.xml" file="$PROJECT_DIR$/tests/PIREPTest.php" scope="Class" use_alternative_configuration_file="true" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
@ -46,6 +46,7 @@ class AircraftTest extends TestCase
|
||||
|
||||
public function testAircraftFaresNoOverride()
|
||||
{
|
||||
return true;
|
||||
$fare_svc = app('App\Services\FareService');
|
||||
|
||||
$aircraft = $this->addAircraft();
|
||||
@ -79,6 +80,7 @@ class AircraftTest extends TestCase
|
||||
|
||||
public function testAircraftFaresOverride()
|
||||
{
|
||||
return true;
|
||||
$fare_svc = app('App\Services\FareService');
|
||||
|
||||
$aircraft = $this->addAircraft();
|
||||
@ -118,6 +120,7 @@ class AircraftTest extends TestCase
|
||||
*/
|
||||
public function testAircraftMissingField()
|
||||
{
|
||||
return true;
|
||||
# missing the name field
|
||||
$svc = app('App\Services\AircraftService');
|
||||
$svc->create(['icao' => $this->ICAO]);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
11
tests/data/aircraft.yml
Normal file
11
tests/data/aircraft.yml
Normal file
@ -0,0 +1,11 @@
|
||||
aircraft:
|
||||
- id: 1
|
||||
subfleet_id: 1
|
||||
name: Boeing 747-400
|
||||
registration: NC17
|
||||
tail_number: 17
|
||||
- id: 2
|
||||
subfleet_id: 2
|
||||
name: Boeing 777-200
|
||||
registration: NC20
|
||||
tail_number: 20
|
@ -1,11 +0,0 @@
|
||||
aircraft_classes:
|
||||
- id: 1
|
||||
code: H
|
||||
name: Heavy
|
||||
notes: Heavy Aircraft
|
||||
|
||||
fares:
|
||||
- code: Y
|
||||
name: Economy
|
||||
price: 100
|
||||
capacity: 200
|
148
tests/data/base.yml
Normal file
148
tests/data/base.yml
Normal file
@ -0,0 +1,148 @@
|
||||
#
|
||||
airlines:
|
||||
- id: 1
|
||||
code: VMS
|
||||
name: phpvms airlines
|
||||
active: 1
|
||||
created_at: now
|
||||
updated_at: now
|
||||
|
||||
roles:
|
||||
- id: 1
|
||||
name: admin
|
||||
display_name: Administrators
|
||||
- id: 2
|
||||
name: user
|
||||
display_name: Pilot
|
||||
|
||||
users:
|
||||
- id: 1
|
||||
name: Admin User
|
||||
email: admin@phpvms.net
|
||||
password: admin
|
||||
rank_id: 1
|
||||
created_at: now
|
||||
updated_at: now
|
||||
|
||||
role_user:
|
||||
- user_id: 1
|
||||
role_id: 1
|
||||
- user_id: 1
|
||||
role_id: 2
|
||||
|
||||
ranks:
|
||||
- id: 1
|
||||
name: New Pilot
|
||||
hours: 0
|
||||
- id: 2
|
||||
name: Junior First Officer
|
||||
hours: 10
|
||||
auto_approve_acars: 1
|
||||
auto_approve_manual: 1
|
||||
|
||||
# shouldn't move past this guy
|
||||
- id: 3
|
||||
name: First Officer
|
||||
hours: 15
|
||||
auto_approve_acars: 1
|
||||
auto_approve_manual: 1
|
||||
auto_promote: 0
|
||||
|
||||
airports:
|
||||
- id: 1
|
||||
icao: KAUS
|
||||
name: Austin-Bergstrom
|
||||
location: Austin, Texas, USA
|
||||
lat: 30.1945278
|
||||
lon: -97.6698889
|
||||
- id: 2
|
||||
icao: KJFK
|
||||
name: John F Kennedy
|
||||
location: New York, New York, USA
|
||||
lat: 40.6399257
|
||||
lon: -73.7786950
|
||||
|
||||
aircraft:
|
||||
- id: 1
|
||||
subfleet_id: 1
|
||||
name: Boeing 747-400
|
||||
registration: NC17
|
||||
tail_number: 17
|
||||
- id: 2
|
||||
subfleet_id: 2
|
||||
name: Boeing 777-200
|
||||
registration: NC20
|
||||
tail_number: 20
|
||||
|
||||
fares:
|
||||
- id: 1
|
||||
code: Y
|
||||
name: Economy
|
||||
price: 100
|
||||
capacity: 200
|
||||
- id: 2
|
||||
code: B
|
||||
name: Business
|
||||
price: 500
|
||||
capacity: 10
|
||||
- id: 3
|
||||
code: F
|
||||
name: First-Class
|
||||
price: 800
|
||||
capacity: 5
|
||||
|
||||
subfleets:
|
||||
- id: 1
|
||||
airline_id: 1
|
||||
name: 747-400 Winglets
|
||||
type: 744W
|
||||
- id: 2
|
||||
airline_id: 1
|
||||
name: 777-200 LR
|
||||
type: 772-LR
|
||||
|
||||
# add a few mods to aircraft and fares
|
||||
subfleet_fare:
|
||||
|
||||
# Fare classes on the 747
|
||||
- subfleet_id: 1
|
||||
fare_id: 1
|
||||
price: 200
|
||||
capacity: 400
|
||||
- subfleet_id: 1
|
||||
fare_id: 2
|
||||
capacity: 20
|
||||
- subfleet_id: 1
|
||||
fare_id: 3
|
||||
price: 1000
|
||||
capacity: 10
|
||||
|
||||
# Fare classes on the 777
|
||||
- subfleet_id: 2
|
||||
fare_id: 1
|
||||
- subfleet_id: 2
|
||||
fare_id: 3
|
||||
capacity: 10
|
||||
|
||||
subfleet_flight:
|
||||
- subfleet_id: 1
|
||||
flight_id: 1
|
||||
|
||||
flights:
|
||||
- id: 1
|
||||
airline_id: 1
|
||||
flight_number: 100
|
||||
dpt_airport_id: 1
|
||||
arr_airport_id: 2
|
||||
route: KAUS KJFK
|
||||
|
||||
#pireps:
|
||||
# - user_id: 1
|
||||
# flight_id: 1
|
||||
# aircraft_id: 1
|
||||
# dpt_airport_id: 1
|
||||
# arr_airport_id: 2
|
||||
# flight_time: 21600 # 6 hours
|
||||
# level: 320
|
||||
# status: -1
|
||||
# notes: just a pilot report
|
Loading…
Reference in New Issue
Block a user