Add tests for the duplicate PIREP via prefile/API
This commit is contained in:
@@ -37,7 +37,8 @@ class AcarsTest extends TestCase
|
||||
'aircraft_id' => $aircraft->id,
|
||||
'dpt_airport_id' => $airport->icao,
|
||||
'arr_airport_id' => $airport->icao,
|
||||
'altitude' => 38000,
|
||||
'flight_number' => '6000',
|
||||
'level' => 38000,
|
||||
'planned_flight_time' => 120,
|
||||
'route' => 'POINTA POINTB',
|
||||
];
|
||||
@@ -115,4 +116,24 @@ class AcarsTest extends TestCase
|
||||
$body = $response->json();
|
||||
$this->assertEquals($dt, $body[0]['sim_time']);*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to refile the same PIREP
|
||||
*/
|
||||
public function testDuplicatePirep()
|
||||
{
|
||||
$uri = '/api/pireps/prefile';
|
||||
$user = factory(App\Models\User::class)->create();
|
||||
$pirep = factory(App\Models\Pirep::class)->make(['id' => ''])->toArray();
|
||||
|
||||
$response = $this->withHeaders($this->apiHeaders())->post($uri, $pirep);
|
||||
// $response = $this->withHeaders($this->headers($user->api_key))->post($uri, $pirep);
|
||||
$response->assertStatus(201);
|
||||
$pirep = $response->json();
|
||||
|
||||
$response = $this->withHeaders($this->apiHeaders())->post($uri, $pirep);
|
||||
$response->assertStatus(200);
|
||||
$body = $response->json();
|
||||
echo $body['id'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,10 +171,7 @@ class PIREPTest extends TestCase
|
||||
*/
|
||||
public function testDuplicatePireps()
|
||||
{
|
||||
$pirep = factory(Pirep::class)->create([
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
'updated_at' => Carbon::now()->toDateTimeString()
|
||||
]);
|
||||
$pirep = factory(Pirep::class)->create();
|
||||
|
||||
# This should find itself...
|
||||
$dupe_pirep = $this->pirepSvc->findDuplicate($pirep);
|
||||
@@ -187,8 +184,7 @@ class PIREPTest extends TestCase
|
||||
|
||||
$minutes = setting('pireps.duplicate_check_time') + 1;
|
||||
$pirep = factory(Pirep::class)->create([
|
||||
'created_at' => Carbon::now()->subMinutes($minutes)->toDateTimeString(),
|
||||
'updated_at' => Carbon::now()->subMinutes($minutes)->toDateTimeString()
|
||||
'created_at' => Carbon::now()->subMinutes($minutes)->toDateTimeString()
|
||||
]);
|
||||
|
||||
# This should find itself...
|
||||
|
||||
@@ -27,6 +27,14 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
return self::$auth_headers;
|
||||
}
|
||||
|
||||
public function headers($api_key)
|
||||
{
|
||||
return [
|
||||
'content-type' => 'application/json',
|
||||
'x-api-key' => $api_key
|
||||
];
|
||||
}
|
||||
|
||||
public function __construct($name = null, array $data = [], $dataName = '') {
|
||||
parent::__construct($name, $data, $dataName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user