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