|
@@ 163-185 (lines=23) @@
|
| 160 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testUpdateRole |
| 161 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
| 162 |
|
*/ |
| 163 |
|
public function testUpdateRoleThrowsUnauthorizedException() |
| 164 |
|
{ |
| 165 |
|
$repository = $this->getRepository(); |
| 166 |
|
$roleService = $repository->getRoleService(); |
| 167 |
|
|
| 168 |
|
/* BEGIN: Use Case */ |
| 169 |
|
$user = $this->createUserVersion1(); |
| 170 |
|
|
| 171 |
|
$role = $this->createRole(); |
| 172 |
|
|
| 173 |
|
// Set "Editor" user as current user. |
| 174 |
|
$repository->setCurrentUser($user); |
| 175 |
|
|
| 176 |
|
// Get a new role update struct and set new values |
| 177 |
|
$roleUpdateStruct = $roleService->newRoleUpdateStruct(); |
| 178 |
|
|
| 179 |
|
// @todo uncomment when support for multilingual names and descriptions is added EZP-24776 |
| 180 |
|
// $roleUpdateStruct->mainLanguageCode = 'eng-US'; |
| 181 |
|
|
| 182 |
|
// This call will fail with an "UnauthorizedException" |
| 183 |
|
$roleService->updateRole($role, $roleUpdateStruct); |
| 184 |
|
/* END: Use Case */ |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
/** |
| 188 |
|
* Test for the deleteRole() method. |
|
@@ 330-350 (lines=21) @@
|
| 327 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testDeletePolicy |
| 328 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
| 329 |
|
*/ |
| 330 |
|
public function testDeletePolicyThrowsUnauthorizedException() |
| 331 |
|
{ |
| 332 |
|
$repository = $this->getRepository(); |
| 333 |
|
$roleService = $repository->getRoleService(); |
| 334 |
|
|
| 335 |
|
/* BEGIN: Use Case */ |
| 336 |
|
$user = $this->createUserVersion1(); |
| 337 |
|
|
| 338 |
|
$role = $this->createRole(); |
| 339 |
|
|
| 340 |
|
// Get first role policy |
| 341 |
|
$policies = $role->getPolicies(); |
| 342 |
|
$policy = reset($policies); |
| 343 |
|
|
| 344 |
|
// Set "Editor" user as current user. |
| 345 |
|
$repository->setCurrentUser($user); |
| 346 |
|
|
| 347 |
|
// This call will fail with an "UnauthorizedException" |
| 348 |
|
$roleService->deletePolicy($policy); |
| 349 |
|
/* END: Use Case */ |
| 350 |
|
} |
| 351 |
|
|
| 352 |
|
/** |
| 353 |
|
* Test for the assignRoleToUserGroup() method. |
|
@@ 525-544 (lines=20) @@
|
| 522 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testUnassignRoleFromUser |
| 523 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
| 524 |
|
*/ |
| 525 |
|
public function testUnassignRoleFromUserThrowsUnauthorizedException() |
| 526 |
|
{ |
| 527 |
|
$repository = $this->getRepository(); |
| 528 |
|
$roleService = $repository->getRoleService(); |
| 529 |
|
|
| 530 |
|
/* BEGIN: Use Case */ |
| 531 |
|
$user = $this->createUserVersion1(); |
| 532 |
|
|
| 533 |
|
$role = $this->createRole(); |
| 534 |
|
|
| 535 |
|
// Assign new role to "Editor" user |
| 536 |
|
$roleService->assignRoleToUser($role, $user); |
| 537 |
|
|
| 538 |
|
// Set "Editor" user as current user. |
| 539 |
|
$repository->setCurrentUser($user); |
| 540 |
|
|
| 541 |
|
// This call will fail with an "UnauthorizedException" |
| 542 |
|
$roleService->unassignRoleFromUser($role, $user); |
| 543 |
|
/* END: Use Case */ |
| 544 |
|
} |
| 545 |
|
|
| 546 |
|
/** |
| 547 |
|
* Test for the getRoleAssignments() method. |