mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 16:13:50 +00:00
Do not block transition in EntityWorkflow when the user is member of a dest user group
- refactor EntityWorkflowGuardTransition + tests - allow to find easily user within userGroup by adding a dedicated method to UserGroup::contains
This commit is contained in:
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Tests\Workflow\EventSubscriber;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Entity\UserGroup;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||
use Chill\MainBundle\Security\Authorization\EntityWorkflowTransitionVoter;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
@@ -145,6 +146,11 @@ class EntityWorkflowGuardTransitionTest extends TestCase
|
||||
yield [self::buildEntityWorkflow([new User()]), 'transition1', null, false, 'd9e39a18-704c-11ef-b235-8fe0619caee7'];
|
||||
yield [self::buildEntityWorkflow([$user = new User()]), 'transition3', $user, false, '5b6b95e0-704d-11ef-a5a9-4b6fc11a8eeb'];
|
||||
yield [self::buildEntityWorkflow([$user = new User()]), 'transition3', $user, true, '5b6b95e0-704d-11ef-a5a9-4b6fc11a8eeb'];
|
||||
|
||||
$userGroup = new UserGroup();
|
||||
$userGroup->addUser(new User());
|
||||
|
||||
yield [self::buildEntityWorkflow([$userGroup]), 'transition1', new User(), false, 'f3eeb57c-7532-11ec-9495-e7942a2ac7bc'];
|
||||
}
|
||||
|
||||
public static function provideValidTransition(): iterable
|
||||
@@ -159,6 +165,10 @@ class EntityWorkflowGuardTransitionTest extends TestCase
|
||||
// transition allowed thanks to permission "apply all transitions"
|
||||
yield [self::buildEntityWorkflow([new User()]), 'transition1', new User(), true, 'step1'];
|
||||
yield [self::buildEntityWorkflow([new User()]), 'transition2', new User(), true, 'step2'];
|
||||
|
||||
$userGroup = new UserGroup();
|
||||
$userGroup->addUser($u = new User());
|
||||
yield [self::buildEntityWorkflow([$userGroup]), 'transition1', $u, false, 'step1'];
|
||||
}
|
||||
|
||||
public static function buildEntityWorkflow(array $futureDestUsers): EntityWorkflow
|
||||
|
Reference in New Issue
Block a user