I'm asking this because sometime this permission could already exist and my test would fail, also in my test i don't wan't to specify label and guard_name and others unnecessary parameters.
I have migration that create Permission but sometime this permission could be missing because i've created new models and forgot to add each ew permission into the migration (is this the right way?).
In your test, you can choose to use RefreshDatabase to reset all your database or DatabaseTransactions to remove everything you added in your test.
I think you are doing some test with your Permission class which does not delete what you added previously, that's why you have the Permission… or not.
When you run php artisan test, it's not running sequentially, if a previous test is executed before your current test (with the firstOrCreate), the Permission already exists, then you can't create it.
I've migration who create some permissions, that's why i wan't to use firstOrCreate, if doesn't exist he should create it using his factory, i thought there was a way to do it through factory itself
But with the Model i cannot pass the factory because he will create different model everytime, even if i specify the name other properties will be different. Probably i will go with the first