File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 44
55use Maklad \Permission \Exceptions \GuardDoesNotMatch ;
66use Maklad \Permission \Exceptions \PermissionDoesNotExist ;
7+ use Maklad \Permission \Models \Permission ;
78use Maklad \Permission \Models \Role ;
89use Monolog \Logger ;
910
@@ -375,4 +376,28 @@ public function it_can_sync_roles_from_a_string_on_a_permission()
375376
376377 $ this ->assertTrue ($ this ->testUserPermission ->hasRole ('testRole2 ' ));
377378 }
379+
380+ /** @test
381+ * @throws \ReflectionException
382+ */
383+ public function it_can_determine_that_a_user_has_all_of_the_given_roles ()
384+ {
385+ $ permissionModel = app (Permission::class);
386+
387+ $ this ->assertFalse ($ this ->testUser ->hasAllPermissions ('edit-news ' ));
388+
389+ $ this ->assertFalse ($ this ->testUser ->hasAllPermissions ($ permissionModel ->all ()->all ()));
390+
391+ $ this ->testUser ->givePermissionTo ('edit-articles ' );
392+
393+ $ this ->refreshTestUser ();
394+
395+ $ this ->assertFalse ($ this ->testUser ->hasAllPermissions (['edit-news ' , 'edit-articles ' ]));
396+
397+ $ this ->testUser ->givePermissionTo ('edit-news ' );
398+
399+ $ this ->refreshTestUser ();
400+
401+ $ this ->assertTrue ($ this ->testUser ->hasAllPermissions ('edit-news ' , 'edit-articles ' ));
402+ }
378403}
You can’t perform that action at this time.
0 commit comments