From dd629b2af8f7d05497de9f85671eb00d3794cff2 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Thu, 4 Jan 2018 21:21:51 -0600 Subject: [PATCH] Make sure arr_airport and dep_airport are included in PIREP prefile response #120 --- app/Http/Resources/Pirep.php | 9 ++++++++- tests/AcarsTest.php | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Http/Resources/Pirep.php b/app/Http/Resources/Pirep.php index 67cab45f..34c60e4f 100644 --- a/app/Http/Resources/Pirep.php +++ b/app/Http/Resources/Pirep.php @@ -14,6 +14,13 @@ class Pirep extends Resource */ public function toArray($request) { - return parent::toArray($request); + $pirep = parent::toArray($request); + + $pirep['airline'] = new Airline($this->airline); + $pirep['dpt_airport'] = new Airport($this->dpt_airport); + $pirep['arr_airport'] = new Airport($this->arr_airport); + $pirep['position'] = new Acars($this->position); + + return $pirep; } } diff --git a/tests/AcarsTest.php b/tests/AcarsTest.php index bdd6e336..6a2c5fc8 100644 --- a/tests/AcarsTest.php +++ b/tests/AcarsTest.php @@ -82,7 +82,10 @@ class AcarsTest extends TestCase $response->assertStatus(201); # Get the PIREP ID - $pirep_id = $response->json()['id']; + $body = $response->json(); + $pirep_id = $body['id']; + + $this->assertHasKeys($body, ['airline', 'arr_airport', 'dpt_airport', 'position']); $this->assertNotNull($pirep_id); # Check the PIREP state and status