@@ -70,6 +70,9 @@ protected function setUp(): void
70
70
71
71
// Note: this also flushes the cache from within the migration
72
72
$ this ->setUpDatabase ($ this ->app );
73
+
74
+ $ this ->setUpBaseTestPermissions ($ this ->app );
75
+
73
76
if ($ this ->hasTeams ) {
74
77
setPermissionsTeamId (1 );
75
78
}
@@ -92,9 +95,8 @@ protected function tearDown(): void
92
95
93
96
/**
94
97
* @param \Illuminate\Foundation\Application $app
95
- * @return array
96
98
*/
97
- protected function getPackageProviders ($ app )
99
+ protected function getPackageProviders ($ app ): array
98
100
{
99
101
return $ this ->getLaravelVersion () < 9 ? [
100
102
PermissionServiceProvider::class,
@@ -196,13 +198,25 @@ protected function setUpDatabase($app)
196
198
197
199
$ this ->
testUser = User::
create ([
'email ' =>
'[email protected] ' ]);
198
200
$ 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
+ {
199
210
$ this ->testUserRole = $ app [Role::class]->create (['name ' => 'testRole ' ]);
200
211
$ app [Role::class]->create (['name ' => 'testRole2 ' ]);
201
212
$ this ->testAdminRole = $ app [Role::class]->create (['name ' => 'testAdminRole ' , 'guard_name ' => 'admin ' ]);
202
213
$ this ->testUserPermission = $ app [Permission::class]->create (['name ' => 'edit-articles ' ]);
203
214
$ app [Permission::class]->create (['name ' => 'edit-news ' ]);
204
215
$ 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
+ ]);
206
220
$ app [Permission::class]->create (['name ' => 'Edit News ' ]);
207
221
}
208
222
0 commit comments