Tests now use factory-generated data, wired up before cleaning up some of the fixture data

This commit is contained in:
Nabeel Shahzad
2017-12-12 21:50:55 -06:00
parent 37d83a65c3
commit f3dea588d9
11 changed files with 209 additions and 77 deletions

View File

@@ -6,25 +6,31 @@ use Faker\Generator as Faker;
$airlinesAvailable = [1];
$airportsAvailable = [
'KJFK',
'KAUS',
'EGLL',
];
$factory->define(App\Models\Flight::class, function (Faker $faker) use ($airportsAvailable, $airlinesAvailable) {
$factory->define(App\Models\Flight::class, function (Faker $faker) use ($airlinesAvailable) {
return [
'id' => $faker->sha1,
'flight_number' => $faker->numberBetween(),
'airline_id' => $faker->randomElement($airlinesAvailable),
'dpt_airport_id' => $faker->randomElement($airportsAvailable),
'arr_airport_id' => $faker->randomElement($airportsAvailable),
'route' => $faker->text(),
'flight_number' => $faker->text(10),
'route_code' => $faker->randomElement(['', $faker->text(5)]),
'route_leg' => $faker->randomElement(['', $faker->text(5)]),
'dpt_airport_id' => function() {
return factory(App\Models\Airport::class)->create()->id;
},
'arr_airport_id' => function () {
return factory(App\Models\Airport::class)->create()->id;
},
'alt_airport_id' => function () {
return factory(App\Models\Airport::class)->create()->id;
},
'route' => $faker->randomElement(['', $faker->text(5)]),
'dpt_time' => $faker->time(),
'arr_time' => $faker->time(),
'flight_time' => $faker->randomFloat(2),
'has_bid' => false,
'active' => true,
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
'updated_at' => function (array $pirep) {
return $pirep['created_at'];
},
];
});