|
@@ 1691-1711 (lines=21) @@
|
| 1688 |
|
* @see \eZ\Publish\API\Repository\RoleService::assignRoleToUser() |
| 1689 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testGetRoleAssignments |
| 1690 |
|
*/ |
| 1691 |
|
public function testAssignRoleToUser() |
| 1692 |
|
{ |
| 1693 |
|
$repository = $this->getRepository(); |
| 1694 |
|
$roleService = $repository->getRoleService(); |
| 1695 |
|
|
| 1696 |
|
/* BEGIN: Use Case */ |
| 1697 |
|
$user = $this->createUserVersion1(); |
| 1698 |
|
|
| 1699 |
|
// Load the existing "Administrator" role |
| 1700 |
|
$role = $roleService->loadRoleByIdentifier('Administrator'); |
| 1701 |
|
|
| 1702 |
|
// Assign the "Administrator" role to the newly created user |
| 1703 |
|
$roleService->assignRoleToUser($role, $user); |
| 1704 |
|
|
| 1705 |
|
// The assignments array will contain the new role<->user assignment |
| 1706 |
|
$roleAssignments = $roleService->getRoleAssignments($role); |
| 1707 |
|
/* END: Use Case */ |
| 1708 |
|
|
| 1709 |
|
// Administrator + Example User |
| 1710 |
|
$this->assertCount(2, $roleAssignments); |
| 1711 |
|
} |
| 1712 |
|
|
| 1713 |
|
/** |
| 1714 |
|
* Test for the assignRoleToUser() method. |
|
@@ 2105-2125 (lines=21) @@
|
| 2102 |
|
* @see \eZ\Publish\API\Repository\RoleService::assignRoleToUserGroup() |
| 2103 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testGetRoleAssignments |
| 2104 |
|
*/ |
| 2105 |
|
public function testAssignRoleToUserGroup() |
| 2106 |
|
{ |
| 2107 |
|
$repository = $this->getRepository(); |
| 2108 |
|
$roleService = $repository->getRoleService(); |
| 2109 |
|
|
| 2110 |
|
/* BEGIN: Use Case */ |
| 2111 |
|
$userGroup = $this->createUserGroupVersion1(); |
| 2112 |
|
|
| 2113 |
|
// Load the existing "Administrator" role |
| 2114 |
|
$role = $roleService->loadRoleByIdentifier('Administrator'); |
| 2115 |
|
|
| 2116 |
|
// Assign the "Administrator" role to the newly created user group |
| 2117 |
|
$roleService->assignRoleToUserGroup($role, $userGroup); |
| 2118 |
|
|
| 2119 |
|
// The assignments array will contain the new role<->group assignment |
| 2120 |
|
$roleAssignments = $roleService->getRoleAssignments($role); |
| 2121 |
|
/* END: Use Case */ |
| 2122 |
|
|
| 2123 |
|
// Administrator + Example Group |
| 2124 |
|
$this->assertCount(2, $roleAssignments); |
| 2125 |
|
} |
| 2126 |
|
|
| 2127 |
|
/** |
| 2128 |
|
* Test for the assignRoleToUserGroup() method. |