feat: derive ROLE_EMPLOYEE from the account's email domain

This commit is contained in:
2026-09-13 12:49:51 +02:00
parent 443a3ed248
commit fab89dead6
7 changed files with 221 additions and 8 deletions
+29
View File
@@ -93,6 +93,35 @@ class RoleTest extends TestCase
self::assertSame([Role::ADMIN => 'Administration'], Role::nominatedFrom($roles));
}
public function testEmployeeIsGrantedOutrightAndDisplacesTheCustomerFallback(): void
{
// The claim does not come from the CRM, but it travels the same path as one.
self::assertSame([Role::EMPLOYEE], Role::sync([], [Role::EMPLOYEE]));
}
public function testEmployeeIsRevokedOnceItIsNoLongerClaimed(): void
{
// Somebody whose address left the staff domain: no claim, so the role goes, and with no
// effective role left the fallback returns.
self::assertSame([Role::CUSTOMER], Role::sync([Role::EMPLOYEE], []));
}
public function testEmployeeDoesNotShortCircuitTheNominationOfAnAdministrativeRole(): void
{
self::assertSame(
[Role::EMPLOYEE, Role::pending(Role::ADMIN)],
Role::sync([], [Role::EMPLOYEE, Role::ADMIN]),
);
}
public function testEmployeeAndTeamerCoexist(): void
{
self::assertSame(
[Role::TEAMER, Role::EMPLOYEE],
Role::sync([], [Role::TEAMER, Role::EMPLOYEE]),
);
}
public function testEveryRoleAndNominationHasALabel(): void
{
$labels = Role::labels();