|
@@ 286-310 (lines=25) @@
|
| 283 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testRemovePolicyByRoleDraft |
| 284 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
| 285 |
|
*/ |
| 286 |
|
public function testDeletePolicyThrowsUnauthorizedException() |
| 287 |
|
{ |
| 288 |
|
$this->expectException(\eZ\Publish\API\Repository\Exceptions\UnauthorizedException::class); |
| 289 |
|
|
| 290 |
|
$repository = $this->getRepository(); |
| 291 |
|
$roleService = $repository->getRoleService(); |
| 292 |
|
$permissionResolver = $repository->getPermissionResolver(); |
| 293 |
|
|
| 294 |
|
/* BEGIN: Use Case */ |
| 295 |
|
$user = $this->createUserVersion1(); |
| 296 |
|
|
| 297 |
|
$role = $this->createRole(); |
| 298 |
|
|
| 299 |
|
// Get first role policy |
| 300 |
|
$roleDraft = $roleService->createRoleDraft($role); |
| 301 |
|
$policiesDrafts = $roleDraft->getPolicies(); |
| 302 |
|
$policyDraft = reset($policiesDrafts); |
| 303 |
|
|
| 304 |
|
// Set "Editor" user as current user. |
| 305 |
|
$permissionResolver->setCurrentUserReference($user); |
| 306 |
|
|
| 307 |
|
// This call will fail with an "UnauthorizedException" |
| 308 |
|
$roleService->removePolicyByRoleDraft($roleDraft, $policyDraft); |
| 309 |
|
/* END: Use Case */ |
| 310 |
|
} |
| 311 |
|
|
| 312 |
|
/** |
| 313 |
|
* Test for the assignRoleToUserGroup() method. |
|
@@ 319-344 (lines=26) @@
|
| 316 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testAssignRoleToUserGroup |
| 317 |
|
* @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
| 318 |
|
*/ |
| 319 |
|
public function testAssignRoleToUserGroupThrowsUnauthorizedException() |
| 320 |
|
{ |
| 321 |
|
$this->expectException(\eZ\Publish\API\Repository\Exceptions\UnauthorizedException::class); |
| 322 |
|
|
| 323 |
|
$repository = $this->getRepository(); |
| 324 |
|
$userService = $repository->getUserService(); |
| 325 |
|
$roleService = $repository->getRoleService(); |
| 326 |
|
$permissionResolver = $repository->getPermissionResolver(); |
| 327 |
|
|
| 328 |
|
$editorsGroupId = $this->generateId('group', 13); |
| 329 |
|
|
| 330 |
|
/* BEGIN: Use Case */ |
| 331 |
|
$user = $this->createUserVersion1(); |
| 332 |
|
|
| 333 |
|
$role = $this->createRole(); |
| 334 |
|
|
| 335 |
|
// Load the "Editors" user group |
| 336 |
|
$userGroup = $userService->loadUserGroup($editorsGroupId); |
| 337 |
|
|
| 338 |
|
// Set "Editor" user as current user. |
| 339 |
|
$permissionResolver->setCurrentUserReference($user); |
| 340 |
|
|
| 341 |
|
// This call will fail with an "UnauthorizedException" |
| 342 |
|
$roleService->assignRoleToUserGroup($role, $userGroup); |
| 343 |
|
/* END: Use Case */ |
| 344 |
|
} |
| 345 |
|
|
| 346 |
|
/** |
| 347 |
|
* Test for the assignRoleToUserGroup() method. |