@@ -26,8 +26,8 @@ abstract class TestCase extends Orchestra
26
26
*/
27
27
public function tearDown (): void
28
28
{
29
- User::truncate ();
30
- Admin::truncate ();
29
+ User::query ()-> truncate ();
30
+ Admin::query ()-> truncate ();
31
31
$ this ->app [Role::class]::truncate ();
32
32
$ this ->app [Permission::class]::truncate ();
33
33
}
@@ -53,12 +53,12 @@ public function setUp(): void
53
53
$ this ->reloadPermissions ();
54
54
55
55
$ this ->testUser = User::first ();
56
- $ this ->testUserRole = \ app (\ config ('permission.models.role ' ))->where ('name ' , 'testRole ' )->first ();
57
- $ this ->testUserPermission = \ app (\ config ('permission.models.permission ' ))->where ('name ' , 'edit-articles ' )->first ();
56
+ $ this ->testUserRole = app (config ('permission.models.role ' ))->where ('name ' , 'testRole ' )->first ();
57
+ $ this ->testUserPermission = app (config ('permission.models.permission ' ))->where ('name ' , 'edit-articles ' )->first ();
58
58
59
59
$ this ->testAdmin = Admin::first ();
60
- $ this ->testAdminRole = \ app (\ config ('permission.models.role ' ))->where ('name ' , 'testAdminRole ' )->first ();
61
- $ this ->testAdminPermission = \ app (\ config ('permission.models.permission ' ))->where ('name ' , 'admin-permission ' )->first ();
60
+ $ this ->testAdminRole = app (config ('permission.models.role ' ))->where ('name ' , 'testAdminRole ' )->first ();
61
+ $ this ->testAdminPermission = app (config ('permission.models.permission ' ))->where ('name ' , 'admin-permission ' )->first ();
62
62
63
63
$ this ->clearLogTestHandler ();
64
64
@@ -70,7 +70,8 @@ public function setUp(): void
70
70
*
71
71
* @return array
72
72
*/
73
- protected function getPackageProviders ($ app ): array {
73
+ protected function getPackageProviders ($ app ): array
74
+ {
74
75
return [
75
76
PermissionServiceProvider::class,
76
77
MongodbServiceProvider::class,
@@ -110,11 +111,11 @@ protected function getEnvironmentSetUp($app)
110
111
*
111
112
* @return bool
112
113
*/
113
- protected function reloadPermissions ()
114
+ protected function reloadPermissions (): bool
114
115
{
115
- \ app (PermissionRegistrar::class)->forgetCachedPermissions ();
116
+ app (PermissionRegistrar::class)->forgetCachedPermissions ();
116
117
117
- return \ app (PermissionRegistrar::class)->registerPermissions ();
118
+ return app (PermissionRegistrar::class)->registerPermissions ();
118
119
}
119
120
120
121
/**
@@ -135,7 +136,7 @@ public function refreshTestAdmin()
135
136
136
137
protected function clearLogTestHandler ()
137
138
{
138
- \ collect ($ this ->app ['log ' ]->getLogger ()->getHandlers ())->filter (function ($ handler ) {
139
+ collect ($ this ->app ['log ' ]->getLogger ()->getHandlers ())->filter (function ($ handler ) {
139
140
return $ handler instanceof TestHandler;
140
141
})->first ()->clear ();
141
142
}
@@ -156,21 +157,23 @@ protected function assertLogged($message, $level)
156
157
*
157
158
* @return bool
158
159
*/
159
- protected function hasLog ($ message , $ level ): bool {
160
- return \collect ($ this ->app ['log ' ]->getLogger ()->getHandlers ())->filter (function ($ handler ) use (
161
- $ message ,
162
- $ level
163
- ) {
160
+ protected function hasLog ($ message , $ level ): bool
161
+ {
162
+ return collect ($ this ->app ['log ' ]->getLogger ()->getHandlers ())->filter (function ($ handler ) use (
163
+ $ message ,
164
+ $ level
165
+ ) {
164
166
return $ handler instanceof TestHandler && $ handler ->hasRecordThatContains ($ message , $ level );
165
167
})->count () > 0 ;
166
168
}
167
169
168
170
/**
169
171
* @param $message
172
+ * @param $level
170
173
*/
171
174
protected function assertLogMessage ($ message , $ level )
172
175
{
173
- if (\ config ('permission.log_registration_exception ' )) {
176
+ if (config ('permission.log_registration_exception ' )) {
174
177
$ this ->assertLogged ($ message , $ level );
175
178
} else {
176
179
$ this ->assertNotLogged ($ message , $ level );
@@ -179,10 +182,11 @@ protected function assertLogMessage($message, $level)
179
182
180
183
/**
181
184
* @param $message
185
+ * @param $role_permission
182
186
*/
183
187
protected function assertShowPermission ($ message , $ role_permission )
184
188
{
185
- if (\ config ('permission.display_permission_in_exception ' )) {
189
+ if (config ('permission.display_permission_in_exception ' )) {
186
190
$ this ->assertContains ($ role_permission , $ message );
187
191
} else {
188
192
$ this ->assertStringNotContainsString ($ role_permission , $ message );
0 commit comments