|
@@ 2171-2194 (lines=24) @@
|
| 2168 |
|
* @see \eZ\Publish\API\Repository\RoleService::unassignRoleFromUser() |
| 2169 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testAssignRoleToUser |
| 2170 |
|
*/ |
| 2171 |
|
public function testUnassignRoleFromUser() |
| 2172 |
|
{ |
| 2173 |
|
$repository = $this->getRepository(); |
| 2174 |
|
$roleService = $repository->getRoleService(); |
| 2175 |
|
|
| 2176 |
|
/* BEGIN: Use Case */ |
| 2177 |
|
$user = $this->createUserVersion1(); |
| 2178 |
|
|
| 2179 |
|
// Load the existing "Member" role |
| 2180 |
|
$role = $roleService->loadRoleByIdentifier('Member'); |
| 2181 |
|
|
| 2182 |
|
// Assign the "Member" role to the newly created user |
| 2183 |
|
$roleService->assignRoleToUser($role, $user); |
| 2184 |
|
|
| 2185 |
|
// Unassign user from role |
| 2186 |
|
$roleService->unassignRoleFromUser($role, $user); |
| 2187 |
|
|
| 2188 |
|
// The assignments array will not contain the new role<->user assignment |
| 2189 |
|
$roleAssignments = $roleService->getRoleAssignments($role); |
| 2190 |
|
/* END: Use Case */ |
| 2191 |
|
|
| 2192 |
|
// Members + Editors + Partners |
| 2193 |
|
$this->assertEquals(3, count($roleAssignments)); |
| 2194 |
|
} |
| 2195 |
|
|
| 2196 |
|
/** |
| 2197 |
|
* Test for the unassignRoleFromUser() method. |
|
@@ 2591-2614 (lines=24) @@
|
| 2588 |
|
* @see \eZ\Publish\API\Repository\RoleService::unassignRoleFromUserGroup() |
| 2589 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testAssignRoleToUserGroup |
| 2590 |
|
*/ |
| 2591 |
|
public function testUnassignRoleFromUserGroup() |
| 2592 |
|
{ |
| 2593 |
|
$repository = $this->getRepository(); |
| 2594 |
|
$roleService = $repository->getRoleService(); |
| 2595 |
|
|
| 2596 |
|
/* BEGIN: Use Case */ |
| 2597 |
|
$userGroup = $this->createUserGroupVersion1(); |
| 2598 |
|
|
| 2599 |
|
// Load the existing "Member" role |
| 2600 |
|
$role = $roleService->loadRoleByIdentifier('Member'); |
| 2601 |
|
|
| 2602 |
|
// Assign the "Member" role to the newly created user group |
| 2603 |
|
$roleService->assignRoleToUserGroup($role, $userGroup); |
| 2604 |
|
|
| 2605 |
|
// Unassign group from role |
| 2606 |
|
$roleService->unassignRoleFromUserGroup($role, $userGroup); |
| 2607 |
|
|
| 2608 |
|
// The assignments array will not contain the new role<->group assignment |
| 2609 |
|
$roleAssignments = $roleService->getRoleAssignments($role); |
| 2610 |
|
/* END: Use Case */ |
| 2611 |
|
|
| 2612 |
|
// Members + Editors + Partners |
| 2613 |
|
$this->assertEquals(3, count($roleAssignments)); |
| 2614 |
|
} |
| 2615 |
|
|
| 2616 |
|
/** |
| 2617 |
|
* Test for the unassignRoleFromUserGroup() method. |