From 96fff0248d23b9a524d97266888f1e2518480ff2 Mon Sep 17 00:00:00 2001 From: Nabeel S Date: Mon, 29 Mar 2021 15:49:34 -0400 Subject: [PATCH] Save airport timezone (#1112) * Fix airport timezone lookup * Save timezone to the airport when importing --- app/Models/Airport.php | 1 + app/Services/AirportService.php | 4 ++-- tests/AirportTest.php | 30 ++++++++++++++++++++++++++++++ tests/TestCase.php | 10 ++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 tests/AirportTest.php diff --git a/app/Models/Airport.php b/app/Models/Airport.php index c200afb1..23a8496b 100644 --- a/app/Models/Airport.php +++ b/app/Models/Airport.php @@ -46,6 +46,7 @@ class Airport extends Model 'lon', 'hub', 'timezone', + 'tz', 'ground_handling_cost', 'fuel_100ll_cost', 'fuel_jeta_cost', diff --git a/app/Services/AirportService.php b/app/Services/AirportService.php index 77cd1ad3..a134b841 100644 --- a/app/Services/AirportService.php +++ b/app/Services/AirportService.php @@ -2,7 +2,7 @@ namespace App\Services; -use App\Contracts\AirportLookup as AirportLookupProvider; +use App\Contracts\AirportLookup; use App\Contracts\Metar as MetarProvider; use App\Contracts\Service; use App\Exceptions\AirportNotFound; @@ -23,7 +23,7 @@ class AirportService extends Service private $metarProvider; public function __construct( - AirportLookupProvider $lookupProvider, + AirportLookup $lookupProvider, AirportRepository $airportRepo, MetarProvider $metarProvider ) { diff --git a/tests/AirportTest.php b/tests/AirportTest.php new file mode 100644 index 00000000..9907cd10 --- /dev/null +++ b/tests/AirportTest.php @@ -0,0 +1,30 @@ + 'KJFK', + 'iata' => 'JFK', + 'name' => 'John F Kennedy International Airport', + 'city' => 'New York', + 'country' => 'United States', + 'tz' => 'America/New_York', + 'lat' => 40.63980103, + 'lon' => -73.77890015, + ]; + + $airport = new Airport($airportResponse); + $this->assertEquals($airportResponse['icao'], $airport->icao); + $this->assertEquals($airportResponse['tz'], $airport->timezone); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index 916a9dfd..52113b14 100755 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -88,6 +88,16 @@ abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase }); } + /** + * @param $mocks + */ + protected function addMocks($mocks) + { + $handler = HandlerStack::create($mocks); + $client = new Client(['handler' => $handler]); + $this->client->httpClient = $client; + } + /** * @param $user * @param array $headers