I am very new to testing with PEST and I want to create tests, that required to create a new Client from a factory. The Client must have a permission for what I am using Spatie Permissions.
The issue I have is that have the roles and permissions created before. The same goes to the clients country, where a foreign key exists on a non-nullable column country_id
and that fails, when there is no country before.
So I think I need to seed the database before and before I go crazy with figuring out, how this could eventually work, I want to know, what the correct approach is for that, to finally have a fast testing as well.
My starting point is just the test:
it('creates invoices for clients after registration', function () {
$client = Client::factory()->create();
});