@@ -70,6 +70,9 @@ protected function setUp(): void
7070
7171 // Note: this also flushes the cache from within the migration
7272 $ this ->setUpDatabase ($ this ->app );
73+
74+ $ this ->setUpBaseTestPermissions ($ this ->app );
75+
7376 if ($ this ->hasTeams ) {
7477 setPermissionsTeamId (1 );
7578 }
@@ -92,9 +95,8 @@ protected function tearDown(): void
9295
9396 /**
9497 * @param \Illuminate\Foundation\Application $app
95- * @return array
9698 */
97- protected function getPackageProviders ($ app )
99+ protected function getPackageProviders ($ app ): array
98100 {
99101 return $ this ->getLaravelVersion () < 9 ? [
100102 PermissionServiceProvider::class,
@@ -196,13 +198,25 @@ protected function setUpDatabase($app)
196198
197199 $ this ->
testUser = User::
create ([
'email ' =>
'[email protected] ' ]);
198200 $ this ->
testAdmin = Admin::
create ([
'email ' =>
'[email protected] ' ]);
201+ }
202+
203+ /**
204+ * Set up initial roles and permissions used in many tests
205+ *
206+ * @param \Illuminate\Foundation\Application $app
207+ */
208+ protected function setUpBaseTestPermissions ($ app ): void
209+ {
199210 $ this ->testUserRole = $ app [Role::class]->create (['name ' => 'testRole ' ]);
200211 $ app [Role::class]->create (['name ' => 'testRole2 ' ]);
201212 $ this ->testAdminRole = $ app [Role::class]->create (['name ' => 'testAdminRole ' , 'guard_name ' => 'admin ' ]);
202213 $ this ->testUserPermission = $ app [Permission::class]->create (['name ' => 'edit-articles ' ]);
203214 $ app [Permission::class]->create (['name ' => 'edit-news ' ]);
204215 $ app [Permission::class]->create (['name ' => 'edit-blog ' ]);
205- $ this ->testAdminPermission = $ app [Permission::class]->create (['name ' => 'admin-permission ' , 'guard_name ' => 'admin ' ]);
216+ $ this ->testAdminPermission = $ app [Permission::class]->create ([
217+ 'name ' => 'admin-permission ' ,
218+ 'guard_name ' => 'admin ' ,
219+ ]);
206220 $ app [Permission::class]->create (['name ' => 'Edit News ' ]);
207221 }
208222
0 commit comments