Add pirep fields to the API response; add tests for setting/getting them

This commit is contained in:
Nabeel Shahzad
2018-02-06 13:59:40 -06:00
parent de0c71cb06
commit e69d9f4c38
3 changed files with 30 additions and 0 deletions

View File

@@ -106,6 +106,9 @@ class AcarsTest extends TestCase
'planned_flight_time' => 120,
'route' => 'POINTA POINTB',
'source_name' => 'UnitTest',
'fields' => [
'custom_field' => 'custom_value',
]
];
$response = $this->post($uri, $pirep);
@@ -124,6 +127,28 @@ class AcarsTest extends TestCase
$this->assertEquals(PirepState::IN_PROGRESS, $pirep['state']);
$this->assertEquals(PirepStatus::PREFILE, $pirep['status']);
/**
* Check the fields
*/
$this->assertHasKeys($pirep, ['fields']);
$this->assertEquals('custom_field', $pirep['fields'][0]['name']);
$this->assertEquals('custom_value', $pirep['fields'][0]['value']);
/**
* Update the custom field
*/
$uri = '/api/pireps/' . $pirep_id . '/update';
$this->post($uri, ['fields' => [
'custom_field' => 'custom_value_changed',
]]);
$pirep = $this->getPirep($pirep_id);
$this->assertEquals('custom_value_changed', $pirep['fields'][0]['value']);
/**
* Add some position updates
*/
$uri = '/api/pireps/' . $pirep_id . '/acars/position';
# Test missing positions field