feat: align role assignment logic with myep-team
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Twig;
|
||||
|
||||
use App\Security\Role;
|
||||
use App\Twig\AppRuntime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AppRuntimeRoleLabelsTest extends TestCase
|
||||
{
|
||||
public function testEffectiveRolesAreLabelled(): void
|
||||
{
|
||||
self::assertSame(
|
||||
['Teamer:in', 'Preisrechner'],
|
||||
$this->runtime()->effectiveRoles([Role::TEAMER, Role::GROUPS_MANAGER]),
|
||||
);
|
||||
}
|
||||
|
||||
public function testImplicitRoleUserIsNotListed(): void
|
||||
{
|
||||
self::assertSame(['Administration'], $this->runtime()->effectiveRoles([Role::USER, Role::ADMIN]));
|
||||
self::assertSame([], $this->runtime()->effectiveRoles([Role::USER]));
|
||||
}
|
||||
|
||||
public function testNominationsAreListedApartFromTheEffectiveRoles(): void
|
||||
{
|
||||
$roles = [Role::TEAMER, Role::pending(Role::ADMIN)];
|
||||
|
||||
self::assertSame(['Teamer:in'], $this->runtime()->effectiveRoles($roles));
|
||||
self::assertSame(['Administration'], $this->runtime()->nominatedRoles($roles));
|
||||
}
|
||||
|
||||
public function testUnknownRoleStaysVisible(): void
|
||||
{
|
||||
self::assertSame(['ROLE_LEGACY'], $this->runtime()->effectiveRoles(['ROLE_LEGACY']));
|
||||
}
|
||||
|
||||
private function runtime(): AppRuntime
|
||||
{
|
||||
return (new \ReflectionClass(AppRuntime::class))->newInstanceWithoutConstructor();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user