parent
ede5b74383
commit
d3ec0f4de3
@ -11,7 +11,7 @@ if (!function_exists('createFactoryICAO')) {
|
|||||||
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||||
$max = strlen($characters) - 1;
|
$max = strlen($characters) - 1;
|
||||||
$string = '';
|
$string = '';
|
||||||
for ($i = 0; $i < 4; $i++) {
|
for ($i = 0; $i < 5; $i++) {
|
||||||
try {
|
try {
|
||||||
$string .= $characters[random_int(0, $max)];
|
$string .= $characters[random_int(0, $max)];
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Contracts\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increase Airport ICAO size to 5 chars
|
||||||
|
* https://github.com/nabeelio/phpvms/issues/1052
|
||||||
|
*/
|
||||||
|
class IncreaseIcaoSizes extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('airports', function (Blueprint $table) {
|
||||||
|
$table->string('iata', 5)->change();
|
||||||
|
$table->string('icao', 5)->change();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('pireps', function (Blueprint $table) {
|
||||||
|
$table->string('dpt_airport_id', 5)->change();
|
||||||
|
$table->string('arr_airport_id', 5)->change();
|
||||||
|
$table->string('alt_airport_id', 5)->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -4,9 +4,6 @@ namespace Tests;
|
|||||||
|
|
||||||
use App\Models\Airport;
|
use App\Models\Airport;
|
||||||
|
|
||||||
/**
|
|
||||||
* Test the parsing/support class of the metar
|
|
||||||
*/
|
|
||||||
class AirportTest extends TestCase
|
class AirportTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testSavingAirportFromApiResponse()
|
public function testSavingAirportFromApiResponse()
|
||||||
|
@ -166,6 +166,24 @@ class ApiTest extends TestCase
|
|||||||
$this->get('/api/airports/UNK')->assertStatus(404);
|
$this->get('/api/airports/UNK')->assertStatus(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make sure the airport data is returned
|
||||||
|
*/
|
||||||
|
public function testAirportRequest5Char()
|
||||||
|
{
|
||||||
|
$this->user = factory(User::class)->create();
|
||||||
|
|
||||||
|
/** @var Airport $airport */
|
||||||
|
$airport = factory(Airport::class)->create(['icao' => '5Char']);
|
||||||
|
|
||||||
|
$response = $this->get('/api/airports/'.$airport->icao);
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$response->assertJson(['data' => ['icao' => $airport->icao]]);
|
||||||
|
|
||||||
|
$this->get('/api/airports/UNK')->assertStatus(404);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the airports, test the pagination
|
* Get all the airports, test the pagination
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user