phpunit test using a model with HasSlug trait failing #266
Closed
danyelgithub
started this conversation in
General
Replies: 1 comment
-
I was using Event::fake() in the test and this prevents the trait to work correctly |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi
I got a Laravel Eloquent model that have the slug field as a not-null property in the database. In the application, all works ok. The model use the trait "HasSlug" and the options are set:
public function getSlugOptions(): SlugOptions
{
return SlugOptions::create()
->generateSlugsFrom('name')
->saveSlugsTo('slug');
}
But when I try to create a new model from a request in a phpunit test (only name is provided) the test fails saying the slug field in the database can not be null. Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions