diff --git a/tests/Pest.php b/tests/Pest.php index 2c5012c..a2e3d58 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1,6 +1,8 @@ extend(TestCase::class) - // ->use(RefreshDatabase::class) + ->use(RefreshDatabase::class) ->in('Feature'); /* @@ -44,7 +46,26 @@ | */ -function something() +/** + * Create a user with specific permissions. + */ +function createAuthorizedUser(array $permissions = []): User { - // .. + $user = User::factory()->create(); + + foreach ($permissions as $permission) { + Permission::findOrCreate($permission); + } + + $user->givePermissionTo($permissions); + + return $user; +} + +/** + * Create a user without permissions. + */ +function createUnauthorizedUser(): User +{ + return User::factory()->create(); }