Save airport timezone (#1112)
* Fix airport timezone lookup * Save timezone to the airport when importing
This commit is contained in:
parent
9c4aced837
commit
96fff0248d
@ -46,6 +46,7 @@ class Airport extends Model
|
|||||||
'lon',
|
'lon',
|
||||||
'hub',
|
'hub',
|
||||||
'timezone',
|
'timezone',
|
||||||
|
'tz',
|
||||||
'ground_handling_cost',
|
'ground_handling_cost',
|
||||||
'fuel_100ll_cost',
|
'fuel_100ll_cost',
|
||||||
'fuel_jeta_cost',
|
'fuel_jeta_cost',
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Contracts\AirportLookup as AirportLookupProvider;
|
use App\Contracts\AirportLookup;
|
||||||
use App\Contracts\Metar as MetarProvider;
|
use App\Contracts\Metar as MetarProvider;
|
||||||
use App\Contracts\Service;
|
use App\Contracts\Service;
|
||||||
use App\Exceptions\AirportNotFound;
|
use App\Exceptions\AirportNotFound;
|
||||||
@ -23,7 +23,7 @@ class AirportService extends Service
|
|||||||
private $metarProvider;
|
private $metarProvider;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AirportLookupProvider $lookupProvider,
|
AirportLookup $lookupProvider,
|
||||||
AirportRepository $airportRepo,
|
AirportRepository $airportRepo,
|
||||||
MetarProvider $metarProvider
|
MetarProvider $metarProvider
|
||||||
) {
|
) {
|
||||||
|
30
tests/AirportTest.php
Normal file
30
tests/AirportTest.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests;
|
||||||
|
|
||||||
|
use App\Models\Airport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the parsing/support class of the metar
|
||||||
|
*/
|
||||||
|
class AirportTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testSavingAirportFromApiResponse()
|
||||||
|
{
|
||||||
|
// This is the response from the API
|
||||||
|
$airportResponse = [
|
||||||
|
'icao' => '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);
|
||||||
|
}
|
||||||
|
}
|
@ -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 $user
|
||||||
* @param array $headers
|
* @param array $headers
|
||||||
|
Loading…
Reference in New Issue
Block a user