mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 14:25:00 +00:00
Fix: AuthorizationHelperTest: remove deprecated and deprecation of PrepareScopeTrait
This commit is contained in:
@@ -18,13 +18,12 @@ use Chill\MainBundle\Entity\HasScopeInterface;
|
||||
use Chill\MainBundle\Entity\HasScopesInterface;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\MainBundle\Test\PrepareCenterTrait;
|
||||
use Chill\MainBundle\Test\PrepareScopeTrait;
|
||||
use Chill\MainBundle\Test\PrepareUserTrait;
|
||||
use Chill\MainBundle\Test\ProphecyTrait;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use function array_map;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
@@ -198,24 +197,6 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function testFindUsersReaching()
|
||||
{
|
||||
$centerA = self::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository(Center::class)
|
||||
->findOneByName('Center A');
|
||||
|
||||
$users = $this->getAuthorizationHelper()
|
||||
->findUsersReaching(
|
||||
'CHILL_PERSON_SEE',
|
||||
$centerA
|
||||
);
|
||||
|
||||
$usernames = array_map(static fn (User $u) => $u->getUsername(), $users);
|
||||
|
||||
$this->assertContains('center a_social', $usernames);
|
||||
}
|
||||
|
||||
public function testGetParentRoles()
|
||||
{
|
||||
$parentRoles = $this->getAuthorizationHelper()
|
||||
@@ -272,7 +253,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->getProphet()->prophesize();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class);
|
||||
$entity->getCenter()->willReturn($center);
|
||||
@@ -338,7 +319,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->getProphet()->prophesize();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement(HasCentersInterface::class);
|
||||
$entity->willImplement(HasScopesInterface::class);
|
||||
$entity->getCenters()->willReturn([$centerA, $centerB]);
|
||||
@@ -360,7 +341,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->getProphet()->prophesize();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement(HasCentersInterface::class);
|
||||
$entity->getCenters()->willReturn([$center, $centerB]);
|
||||
|
||||
@@ -379,7 +360,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->getProphet()->prophesize();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->getCenter()->willReturn($center);
|
||||
|
||||
@@ -403,7 +384,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
]);
|
||||
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->getProphet()->prophesize();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->getCenter()->willReturn($center);
|
||||
|
||||
@@ -427,7 +408,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->getProphet()->prophesize();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class);
|
||||
$entity->getCenter()->willReturn($centerB);
|
||||
@@ -448,7 +429,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->getProphet()->prophesize();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->getCenter()->willReturn($center);
|
||||
|
||||
@@ -467,7 +448,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->getProphet()->prophesize();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class);
|
||||
$entity->getCenter()->willReturn($center);
|
||||
@@ -499,7 +480,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->getProphet()->prophesize();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->getCenter()->willReturn($centerA);
|
||||
|
||||
@@ -519,7 +500,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->getProphet()->prophesize();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement(HasCenterInterface::class);
|
||||
$entity->willImplement(HasScopeInterface::class);
|
||||
$entity->getCenter()->willReturn($center);
|
||||
@@ -543,7 +524,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->getProphet()->prophesize();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement(HasCentersInterface::class);
|
||||
$entity->willImplement(HasScopesInterface::class);
|
||||
$entity->getCenters()->willReturn([$centerA, $centerB]);
|
||||
@@ -566,7 +547,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->getProphet()->prophesize();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement(HasCentersInterface::class);
|
||||
$entity->getCenters()->willReturn([$centerB, $centerC]);
|
||||
|
||||
@@ -579,6 +560,6 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
private function getAuthorizationHelper()
|
||||
{
|
||||
return self::$container
|
||||
->get('chill.main.security.authorization.helper');
|
||||
->get(AuthorizationHelper::class);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user