I'm coding a laravel package, that interact with User model.
When I test it in browser, everything is OK, because App\User exists, but when I test my plugin, App\User
doesn't exists.
So it fails. I replaced all references of App\User
to Illuminate\Foundation\Auth\User
but my relations fail, my factories fails.
for instance, the User factory:
$factory->define(\Illuminate\Foundation\Auth\User::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'email_verified_at' => now(),
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
'remember_token' => str_random(10),
'firstname' => $faker->firstname,
'lastname' => $faker->lastName,
];
});
Won't work with \Illuminate\Foundation\Auth\User::class
, because it doesn't have all custom fields: email_verified_at
,firstname
,lastname
,etc.
So my tests fail:
11) Xoco70\LaravelTournaments\Tests\SingleEliminationWPrelimTest::it_can_generate_prelim_tree_with_12_fighters
Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 table users has no column named email_verified_at (SQL: insert into "users" ("name", "email", "email_verified_at", "password", "remember_token", "firstname", "lastname", "updated_at", "created_at") values (user, jennifer86@example.org, 2018-10-11 09:14:17, $2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm, KZmf72JC9D, Buster, Hackett, 2018-10-11 09:14:17, 2018-10-11 09:14:17))
or my relations:
public function users()
{
return $this->belongsToMany(\Illuminate\Foundation\Auth\User::class, 'competitor', 'championship_id')
->withPivot('confirmed')
->withTimestamps();
}
Won't work neither.
How should I manage it ?
Aucun commentaire:
Enregistrer un commentaire