mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Methods regarding to role hierarchi are now delegated to a parent role helper.
37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Chill\MainBundle\Tests\Security\Authorization;
|
|
|
|
use Chill\MainBundle\Security\ParentRoleHelper;
|
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
|
|
class ParentRoleHelperTest extends KernelTestCase
|
|
{
|
|
private ParentRoleHelper $parentRoleHelper;
|
|
|
|
public function setUp()
|
|
{
|
|
self::bootKernel();
|
|
$this->parentRoleHelper = self::$container->get(ParentRoleHelper::class);
|
|
}
|
|
|
|
public function testGetReachableRoles()
|
|
{
|
|
// this test will be valid until the role hierarchy for person is changed.
|
|
// this is not perfect but spare us a mock
|
|
|
|
$parentRoles = $this->parentRoleHelper->getParentRoles(PersonVoter::SEE);
|
|
|
|
$this->assertCount(2, $parentRoles);
|
|
$this->assertContains(PersonVoter::CREATE, $parentRoles);
|
|
$this->assertContains(PersonVoter::UPDATE, $parentRoles);
|
|
}
|
|
|
|
public function testIsRoleReached()
|
|
{
|
|
$this->assertTrue($this->parentRoleHelper->isRoleReached(PersonVoter::SEE, PersonVoter::CREATE));
|
|
$this->assertFalse($this->parentRoleHelper->isRoleReached(PersonVoter::SEE, 'foo'));
|
|
}
|
|
}
|