Fix tests for new datatypes
This commit is contained in:
@@ -9,12 +9,14 @@ $factory->define(App\Models\Acars::class, function (Faker $faker) {
|
||||
'log' => $faker->text(100),
|
||||
'lat' => $faker->latitude,
|
||||
'lon' => $faker->longitude,
|
||||
'distance' => $faker->randomFloat(2, 0, 6000),
|
||||
'heading' => $faker->numberBetween(0, 359),
|
||||
'altitude' => $faker->numberBetween(20, 400),
|
||||
'vs' => $faker->numberBetween(-5000, 5000),
|
||||
'gs' => $faker->numberBetween(300, 500),
|
||||
'transponder' => $faker->numberBetween(200, 9999),
|
||||
'autopilot' => $faker->text(10),
|
||||
'fuel' => $faker->randomFloat(2, 100, 1000),
|
||||
'fuel_flow' => $faker->randomFloat(2, 100, 1000),
|
||||
'sim_time' => $faker->dateTime('now', 'UTC'),
|
||||
];
|
||||
|
||||
@@ -348,11 +348,9 @@ class AcarsTest extends TestCase
|
||||
$response->assertStatus(400);
|
||||
|
||||
# Post an ACARS update
|
||||
$acars = factory(App\Models\Acars::class)->make(
|
||||
[
|
||||
'id' => null,
|
||||
]
|
||||
)->toArray();
|
||||
$acars = factory(App\Models\Acars::class)->make(['pirep_id' => $pirep_id])->toArray();
|
||||
|
||||
$acars = $this->transformData($acars);
|
||||
|
||||
$update = ['positions' => [$acars]];
|
||||
$response = $this->post($uri, $update);
|
||||
|
||||
@@ -116,9 +116,13 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function transformData(array $data): array
|
||||
protected function transformData($data)
|
||||
{
|
||||
foreach($data as $key => $value) {
|
||||
if(is_object($value)) {
|
||||
$value = $this->transformData($value);
|
||||
}
|
||||
|
||||
if (is_subclass_of($value, App\Interfaces\Unit::class)) {
|
||||
$data[$key] = $value->__toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user