From 87a0554c2bfc342a42a716ae2db43c8a9842806d Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Wed, 29 Apr 2026 22:09:59 +0700 Subject: [PATCH] feat: add user creation functions with permission handling for authorized and unauthorized users --- tests/Pest.php | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) 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(); }