findRoleById() public méthode

Finds a role with a specific id.
public findRoleById ( integer $id ) : Sulu\Component\Security\Authentication\RoleInterface
$id integer id of the role
Résultat Sulu\Component\Security\Authentication\RoleInterface
 public function testSetPermissionsWithExistingAccessControl()
 {
     $role = new Role();
     $this->roleRepository->findRoleById(1)->willReturn($role);
     $this->maskConverter->convertPermissionsToNumber(['view' => true, 'edit' => false])->willReturn(64);
     $accessControl = $this->prophesize(AccessControl::class);
     $accessControl->setPermissions(64)->shouldBeCalled();
     $this->accessControlRepository->findByTypeAndIdAndRole('AcmeBundle\\Example', 1, 1)->willReturn($accessControl);
     $this->objectManager->persist(Argument::any())->shouldNotBeCalled();
     $this->objectManager->flush()->shouldBeCalled();
     $this->doctrineAccessControlProvider->setPermissions('AcmeBundle\\Example', 1, [1 => ['view' => true, 'edit' => false]]);
 }
 /**
  * Sets the permissions for the object with the given class and id for the given security identity.
  *
  * @param string $type The name of the class to protect
  * @param string $identifier
  * @param $permissions
  */
 public function setPermissions($type, $identifier, $permissions)
 {
     foreach ($permissions as $roleId => $rolePermissions) {
         $accessControl = $this->accessControlRepository->findByTypeAndIdAndRole($type, $identifier, $roleId);
         if ($accessControl) {
             $accessControl->setPermissions($this->maskConverter->convertPermissionsToNumber($rolePermissions));
         } else {
             $role = $this->roleRepository->findRoleById($roleId);
             $accessControl = new AccessControl();
             $accessControl->setPermissions($this->maskConverter->convertPermissionsToNumber($rolePermissions));
             $accessControl->setRole($role);
             $accessControl->setEntityId($identifier);
             $accessControl->setEntityClass($type);
             $this->objectManager->persist($accessControl);
         }
     }
     $this->objectManager->flush();
 }