|
@@ 1879-1899 (lines=21) @@
|
| 1876 |
|
* @see \eZ\Publish\API\Repository\RoleService::assignRoleToUser() |
| 1877 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testGetRoleAssignments |
| 1878 |
|
*/ |
| 1879 |
|
public function testAssignRoleToUser() |
| 1880 |
|
{ |
| 1881 |
|
$repository = $this->getRepository(); |
| 1882 |
|
$roleService = $repository->getRoleService(); |
| 1883 |
|
|
| 1884 |
|
/* BEGIN: Use Case */ |
| 1885 |
|
$user = $this->createUserVersion1(); |
| 1886 |
|
|
| 1887 |
|
// Load the existing "Administrator" role |
| 1888 |
|
$role = $roleService->loadRoleByIdentifier('Administrator'); |
| 1889 |
|
|
| 1890 |
|
// Assign the "Administrator" role to the newly created user |
| 1891 |
|
$roleService->assignRoleToUser($role, $user); |
| 1892 |
|
|
| 1893 |
|
// The assignments array will contain the new role<->user assignment |
| 1894 |
|
$roleAssignments = $roleService->getRoleAssignments($role); |
| 1895 |
|
/* END: Use Case */ |
| 1896 |
|
|
| 1897 |
|
// Administrator + Example User |
| 1898 |
|
$this->assertCount(2, $roleAssignments); |
| 1899 |
|
} |
| 1900 |
|
|
| 1901 |
|
/** |
| 1902 |
|
* Test for the assignRoleToUser() method. |
|
@@ 2293-2313 (lines=21) @@
|
| 2290 |
|
* @see \eZ\Publish\API\Repository\RoleService::assignRoleToUserGroup() |
| 2291 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testGetRoleAssignments |
| 2292 |
|
*/ |
| 2293 |
|
public function testAssignRoleToUserGroup() |
| 2294 |
|
{ |
| 2295 |
|
$repository = $this->getRepository(); |
| 2296 |
|
$roleService = $repository->getRoleService(); |
| 2297 |
|
|
| 2298 |
|
/* BEGIN: Use Case */ |
| 2299 |
|
$userGroup = $this->createUserGroupVersion1(); |
| 2300 |
|
|
| 2301 |
|
// Load the existing "Administrator" role |
| 2302 |
|
$role = $roleService->loadRoleByIdentifier('Administrator'); |
| 2303 |
|
|
| 2304 |
|
// Assign the "Administrator" role to the newly created user group |
| 2305 |
|
$roleService->assignRoleToUserGroup($role, $userGroup); |
| 2306 |
|
|
| 2307 |
|
// The assignments array will contain the new role<->group assignment |
| 2308 |
|
$roleAssignments = $roleService->getRoleAssignments($role); |
| 2309 |
|
/* END: Use Case */ |
| 2310 |
|
|
| 2311 |
|
// Administrator + Example Group |
| 2312 |
|
$this->assertCount(2, $roleAssignments); |
| 2313 |
|
} |
| 2314 |
|
|
| 2315 |
|
/** |
| 2316 |
|
* Test for the assignRoleToUserGroup() method. |