From 8aac412dc6bc2fa7831e3d60f1c61041b48796c1 Mon Sep 17 00:00:00 2001 From: Adrian Gajos Date: Mon, 19 Feb 2024 13:27:01 +0100 Subject: [PATCH] feat(Roles): Support for casting role names to enums --- tests/HasRolesTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/HasRolesTest.php b/tests/HasRolesTest.php index 6011d207..a6ebef1d 100644 --- a/tests/HasRolesTest.php +++ b/tests/HasRolesTest.php @@ -59,6 +59,10 @@ public function it_can_assign_and_remove_a_role_using_enums() $this->assertFalse($this->testUser->hasRole($enum2)); $this->assertFalse($this->testUser->hasRole($enum3)); $this->assertFalse($this->testUser->hasRole($enum4)); + $this->assertFalse($this->testUser->hasRole('user-manager')); + $this->assertFalse($this->testUser->hasRole('writer')); + $this->assertFalse($this->testUser->hasRole('casted_enum-1')); + $this->assertFalse($this->testUser->hasRole('casted_enum-2')); $this->testUser->assignRole($enum1); $this->testUser->assignRole($enum2); @@ -70,10 +74,16 @@ public function it_can_assign_and_remove_a_role_using_enums() $this->assertTrue($this->testUser->hasRole($enum3)); $this->assertTrue($this->testUser->hasRole($enum4)); + $this->assertTrue($this->testUser->hasRole([$enum1, 'writer'])); + $this->assertTrue($this->testUser->hasRole([$enum3, 'casted_enum-2'])); + $this->assertTrue($this->testUser->hasAllRoles([$enum1, $enum2, $enum3, $enum4])); + $this->assertTrue($this->testUser->hasAllRoles(['user-manager', 'writer', 'casted_enum-1', 'casted_enum-2'])); $this->assertFalse($this->testUser->hasAllRoles([$enum1, $enum2, $enum3, $enum4, 'not exist'])); + $this->assertFalse($this->testUser->hasAllRoles(['user-manager', 'writer', 'casted_enum-1', 'casted_enum-2', 'not exist'])); $this->assertTrue($this->testUser->hasExactRoles([$enum4, $enum3, $enum2, $enum1])); + $this->assertTrue($this->testUser->hasExactRoles(['user-manager', 'writer', 'casted_enum-1', 'casted_enum-2'])); $this->testUser->removeRole($enum1);