@@ 2469-2487 (lines=19) @@ | ||
2466 | * |
|
2467 | * @covers \eZ\Publish\API\Repository\RoleService::removeRoleAssignment |
|
2468 | */ |
|
2469 | public function testUnassignRoleByAssignmentThrowsUnauthorizedException() |
|
2470 | { |
|
2471 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\UnauthorizedException::class); |
|
2472 | ||
2473 | $repository = $this->getRepository(); |
|
2474 | $roleService = $repository->getRoleService(); |
|
2475 | ||
2476 | try { |
|
2477 | $adminUserGroup = $repository->getUserService()->loadUserGroup(12); |
|
2478 | $assignments = $roleService->getRoleAssignmentsForUserGroup($adminUserGroup); |
|
2479 | $roleService->removeRoleAssignment($assignments[0]); |
|
2480 | } catch (Exception $e) { |
|
2481 | self::fail( |
|
2482 | 'Unexpected exception: ' . $e->getMessage() . " \n[" . $e->getFile() . ' (' . $e->getLine() . ')]' |
|
2483 | ); |
|
2484 | } |
|
2485 | ||
2486 | $roleService->removeRoleAssignment($assignments[0]); |
|
2487 | } |
|
2488 | ||
2489 | /** |
|
2490 | * Test unassigning role by non-existing assignment. |
|
@@ 2494-2512 (lines=19) @@ | ||
2491 | * |
|
2492 | * @covers \eZ\Publish\API\Repository\RoleService::removeRoleAssignment |
|
2493 | */ |
|
2494 | public function testUnassignRoleByAssignmentThrowsNotFoundException() |
|
2495 | { |
|
2496 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\NotFoundException::class); |
|
2497 | ||
2498 | $repository = $this->getRepository(); |
|
2499 | $roleService = $repository->getRoleService(); |
|
2500 | ||
2501 | try { |
|
2502 | $editorsUserGroup = $repository->getUserService()->loadUserGroup(13); |
|
2503 | $assignments = $roleService->getRoleAssignmentsForUserGroup($editorsUserGroup); |
|
2504 | $roleService->removeRoleAssignment($assignments[0]); |
|
2505 | } catch (Exception $e) { |
|
2506 | self::fail( |
|
2507 | 'Unexpected exception: ' . $e->getMessage() . " \n[" . $e->getFile() . ' (' . $e->getLine() . ')]' |
|
2508 | ); |
|
2509 | } |
|
2510 | ||
2511 | $roleService->removeRoleAssignment($assignments[0]); |
|
2512 | } |
|
2513 | ||
2514 | /** |
|
2515 | * Test for the getRoleAssignmentsForUserGroup() method. |