|
@@ 1831-1851 (lines=21) @@
|
| 1828 |
|
* @see \eZ\Publish\API\Repository\RoleService::assignRoleToUser() |
| 1829 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testGetRoleAssignments |
| 1830 |
|
*/ |
| 1831 |
|
public function testAssignRoleToUser() |
| 1832 |
|
{ |
| 1833 |
|
$repository = $this->getRepository(); |
| 1834 |
|
$roleService = $repository->getRoleService(); |
| 1835 |
|
|
| 1836 |
|
/* BEGIN: Use Case */ |
| 1837 |
|
$user = $this->createUserVersion1(); |
| 1838 |
|
|
| 1839 |
|
// Load the existing "Administrator" role |
| 1840 |
|
$role = $roleService->loadRoleByIdentifier('Administrator'); |
| 1841 |
|
|
| 1842 |
|
// Assign the "Administrator" role to the newly created user |
| 1843 |
|
$roleService->assignRoleToUser($role, $user); |
| 1844 |
|
|
| 1845 |
|
// The assignments array will contain the new role<->user assignment |
| 1846 |
|
$roleAssignments = $roleService->getRoleAssignments($role); |
| 1847 |
|
/* END: Use Case */ |
| 1848 |
|
|
| 1849 |
|
// Administrator + Example User |
| 1850 |
|
$this->assertCount(2, $roleAssignments); |
| 1851 |
|
} |
| 1852 |
|
|
| 1853 |
|
/** |
| 1854 |
|
* Test for the assignRoleToUser() method. |
|
@@ 2245-2265 (lines=21) @@
|
| 2242 |
|
* @see \eZ\Publish\API\Repository\RoleService::assignRoleToUserGroup() |
| 2243 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testGetRoleAssignments |
| 2244 |
|
*/ |
| 2245 |
|
public function testAssignRoleToUserGroup() |
| 2246 |
|
{ |
| 2247 |
|
$repository = $this->getRepository(); |
| 2248 |
|
$roleService = $repository->getRoleService(); |
| 2249 |
|
|
| 2250 |
|
/* BEGIN: Use Case */ |
| 2251 |
|
$userGroup = $this->createUserGroupVersion1(); |
| 2252 |
|
|
| 2253 |
|
// Load the existing "Administrator" role |
| 2254 |
|
$role = $roleService->loadRoleByIdentifier('Administrator'); |
| 2255 |
|
|
| 2256 |
|
// Assign the "Administrator" role to the newly created user group |
| 2257 |
|
$roleService->assignRoleToUserGroup($role, $userGroup); |
| 2258 |
|
|
| 2259 |
|
// The assignments array will contain the new role<->group assignment |
| 2260 |
|
$roleAssignments = $roleService->getRoleAssignments($role); |
| 2261 |
|
/* END: Use Case */ |
| 2262 |
|
|
| 2263 |
|
// Administrator + Example Group |
| 2264 |
|
$this->assertCount(2, $roleAssignments); |
| 2265 |
|
} |
| 2266 |
|
|
| 2267 |
|
/** |
| 2268 |
|
* Test for the assignRoleToUserGroup() method. |