|
@@ 2196-2219 (lines=24) @@
|
| 2193 |
|
* @see \eZ\Publish\API\Repository\RoleService::unassignRoleFromUser() |
| 2194 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testAssignRoleToUser |
| 2195 |
|
*/ |
| 2196 |
|
public function testUnassignRoleFromUser() |
| 2197 |
|
{ |
| 2198 |
|
$repository = $this->getRepository(); |
| 2199 |
|
$roleService = $repository->getRoleService(); |
| 2200 |
|
|
| 2201 |
|
/* BEGIN: Use Case */ |
| 2202 |
|
$user = $this->createUserVersion1(); |
| 2203 |
|
|
| 2204 |
|
// Load the existing "Member" role |
| 2205 |
|
$role = $roleService->loadRoleByIdentifier('Member'); |
| 2206 |
|
|
| 2207 |
|
// Assign the "Member" role to the newly created user |
| 2208 |
|
$roleService->assignRoleToUser($role, $user); |
| 2209 |
|
|
| 2210 |
|
// Unassign user from role |
| 2211 |
|
$roleService->unassignRoleFromUser($role, $user); |
| 2212 |
|
|
| 2213 |
|
// The assignments array will not contain the new role<->user assignment |
| 2214 |
|
$roleAssignments = $roleService->getRoleAssignments($role); |
| 2215 |
|
/* END: Use Case */ |
| 2216 |
|
|
| 2217 |
|
// Members + Editors + Partners |
| 2218 |
|
$this->assertEquals(3, count($roleAssignments)); |
| 2219 |
|
} |
| 2220 |
|
|
| 2221 |
|
/** |
| 2222 |
|
* Test for the unassignRoleFromUser() method. |
|
@@ 2616-2639 (lines=24) @@
|
| 2613 |
|
* @see \eZ\Publish\API\Repository\RoleService::unassignRoleFromUserGroup() |
| 2614 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testAssignRoleToUserGroup |
| 2615 |
|
*/ |
| 2616 |
|
public function testUnassignRoleFromUserGroup() |
| 2617 |
|
{ |
| 2618 |
|
$repository = $this->getRepository(); |
| 2619 |
|
$roleService = $repository->getRoleService(); |
| 2620 |
|
|
| 2621 |
|
/* BEGIN: Use Case */ |
| 2622 |
|
$userGroup = $this->createUserGroupVersion1(); |
| 2623 |
|
|
| 2624 |
|
// Load the existing "Member" role |
| 2625 |
|
$role = $roleService->loadRoleByIdentifier('Member'); |
| 2626 |
|
|
| 2627 |
|
// Assign the "Member" role to the newly created user group |
| 2628 |
|
$roleService->assignRoleToUserGroup($role, $userGroup); |
| 2629 |
|
|
| 2630 |
|
// Unassign group from role |
| 2631 |
|
$roleService->unassignRoleFromUserGroup($role, $userGroup); |
| 2632 |
|
|
| 2633 |
|
// The assignments array will not contain the new role<->group assignment |
| 2634 |
|
$roleAssignments = $roleService->getRoleAssignments($role); |
| 2635 |
|
/* END: Use Case */ |
| 2636 |
|
|
| 2637 |
|
// Members + Editors + Partners |
| 2638 |
|
$this->assertEquals(3, count($roleAssignments)); |
| 2639 |
|
} |
| 2640 |
|
|
| 2641 |
|
/** |
| 2642 |
|
* Test for the unassignRoleFromUserGroup() method. |