| @@ 63-79 (lines=17) @@ | ||
| 60 | * |
|
| 61 | * @throws \ErrorException if a mandatory test fixture not exists. |
|
| 62 | */ |
|
| 63 | public function testUserGroupLimitationForbid() |
|
| 64 | { |
|
| 65 | $repository = $this->getRepository(); |
|
| 66 | ||
| 67 | $userService = $repository->getUserService(); |
|
| 68 | ||
| 69 | /* BEGIN: Use Case */ |
|
| 70 | $user = $this->createUserVersion1(); |
|
| 71 | ||
| 72 | $userGroup = $this->prepareUserGroup(); |
|
| 73 | ||
| 74 | // Assign example user to new group |
|
| 75 | $userService->assignUserToUserGroup($user, $userGroup); |
|
| 76 | ||
| 77 | $this->prepareLimitationAndContent($user, $userGroup); |
|
| 78 | /* END: Use Case */ |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * Prepares the UserGroup fixture. |
|
| @@ 2022-2040 (lines=19) @@ | ||
| 2019 | * @expectedExceptionMessage Argument 'user' is invalid: user is already in the given user group |
|
| 2020 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testAssignUserToUserGroup |
|
| 2021 | */ |
|
| 2022 | public function testAssignUserToUserGroupThrowsInvalidArgumentException() |
|
| 2023 | { |
|
| 2024 | $repository = $this->getRepository(); |
|
| 2025 | $userService = $repository->getUserService(); |
|
| 2026 | ||
| 2027 | $editorsGroupId = $this->generateId('group', 13); |
|
| 2028 | /* BEGIN: Use Case */ |
|
| 2029 | $user = $this->createUserVersion1(); |
|
| 2030 | // $editorsGroupId is the ID of the "Editors" group in an |
|
| 2031 | // eZ Publish demo installation |
|
| 2032 | ||
| 2033 | // This call will fail with an "InvalidArgumentException", because the |
|
| 2034 | // user is already assigned to the "Editors" group |
|
| 2035 | $userService->assignUserToUserGroup( |
|
| 2036 | $user, |
|
| 2037 | $userService->loadUserGroup($editorsGroupId) |
|
| 2038 | ); |
|
| 2039 | /* END: Use Case */ |
|
| 2040 | } |
|
| 2041 | ||
| 2042 | /** |
|
| 2043 | * Test for the unAssignUssrFromUserGroup() method. |
|