I'm trying to run some queries in a service provider for loading permissions into Laravel's Authorization Gate. This works great, but not during testing, and I'm not sure what's going on or if someone could help me out.
Inside my service providers boot method:
foreach (Permission:all() as $permission) {
$gate->define($permission->name, function ($user) use ($permission) {
return $user->hasPermission($permission);
});
}
However, during testing, I get an exception that no table permissions exists even when using the DatabaseMigrations trait on my test case.
Is there another location I can store this logic so it's loaded properly during testing? It seems like there is no where in the application stack I can store this for it to be loaded during testing...
via Steve Bauman