|
@@ 635-647 (lines=13) @@
|
| 632 |
|
* |
| 633 |
|
* @covers \eZ\Publish\API\Repository\RoleService::assignRoleToUserGroup |
| 634 |
|
*/ |
| 635 |
|
public function testAssignRoleToUserGroup() |
| 636 |
|
{ |
| 637 |
|
$roleService = $this->repository->getRoleService(); |
| 638 |
|
|
| 639 |
|
$role = $roleService->loadRole(1); |
| 640 |
|
$userGroup = $this->repository->getUserService()->loadUserGroup(12); |
| 641 |
|
|
| 642 |
|
$originalAssignmentCount = count($roleService->getRoleAssignmentsForUserGroup($userGroup)); |
| 643 |
|
|
| 644 |
|
$roleService->assignRoleToUserGroup($role, $userGroup); |
| 645 |
|
$newAssignmentCount = count($roleService->getRoleAssignmentsForUserGroup($userGroup)); |
| 646 |
|
self::assertEquals($originalAssignmentCount + 1, $newAssignmentCount); |
| 647 |
|
} |
| 648 |
|
|
| 649 |
|
/** |
| 650 |
|
* Test unassigning role from user group. |
|
@@ 654-666 (lines=13) @@
|
| 651 |
|
* |
| 652 |
|
* @covers \eZ\Publish\API\Repository\RoleService::unassignRoleFromUserGroup |
| 653 |
|
*/ |
| 654 |
|
public function testUnassignRoleFromUserGroup() |
| 655 |
|
{ |
| 656 |
|
$roleService = $this->repository->getRoleService(); |
| 657 |
|
|
| 658 |
|
$anonymousRole = $roleService->loadRole(1); |
| 659 |
|
$anonymousUserGroup = $this->repository->getUserService()->loadUserGroup(42); |
| 660 |
|
|
| 661 |
|
$originalAssignmentCount = count($roleService->getRoleAssignmentsForUserGroup($anonymousUserGroup)); |
| 662 |
|
|
| 663 |
|
$roleService->unassignRoleFromUserGroup($anonymousRole, $anonymousUserGroup); |
| 664 |
|
$newAssignmentCount = count($roleService->getRoleAssignmentsForUserGroup($anonymousUserGroup)); |
| 665 |
|
self::assertEquals($originalAssignmentCount - 1, $newAssignmentCount); |
| 666 |
|
} |
| 667 |
|
|
| 668 |
|
/** |
| 669 |
|
* Test unassigning role from user group. |
|
@@ 713-725 (lines=13) @@
|
| 710 |
|
* |
| 711 |
|
* @covers \eZ\Publish\API\Repository\RoleService::assignRoleToUser |
| 712 |
|
*/ |
| 713 |
|
public function testAssignRoleToUser() |
| 714 |
|
{ |
| 715 |
|
$roleService = $this->repository->getRoleService(); |
| 716 |
|
|
| 717 |
|
$role = $roleService->loadRole(2); |
| 718 |
|
$user = $this->repository->getUserService()->loadUser(14); |
| 719 |
|
|
| 720 |
|
$originalAssignmentCount = count($roleService->getRoleAssignmentsForUser($user)); |
| 721 |
|
|
| 722 |
|
$roleService->assignRoleToUser($role, $user); |
| 723 |
|
$newAssignmentCount = count($roleService->getRoleAssignmentsForUser($user)); |
| 724 |
|
self::assertEquals($originalAssignmentCount + 1, $newAssignmentCount); |
| 725 |
|
} |
| 726 |
|
|
| 727 |
|
/** |
| 728 |
|
* Test unassigning role from user. |