| @@ 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. |
|
| @@ 1918-1936 (lines=19) @@ | ||
| 1915 | * @expectedExceptionMessage Argument 'user' is invalid: user is already in the given user group |
|
| 1916 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testAssignUserToUserGroup |
|
| 1917 | */ |
|
| 1918 | public function testAssignUserToUserGroupThrowsInvalidArgumentException() |
|
| 1919 | { |
|
| 1920 | $repository = $this->getRepository(); |
|
| 1921 | $userService = $repository->getUserService(); |
|
| 1922 | ||
| 1923 | $editorsGroupId = $this->generateId('group', 13); |
|
| 1924 | /* BEGIN: Use Case */ |
|
| 1925 | $user = $this->createUserVersion1(); |
|
| 1926 | // $editorsGroupId is the ID of the "Editors" group in an |
|
| 1927 | // eZ Publish demo installation |
|
| 1928 | ||
| 1929 | // This call will fail with an "InvalidArgumentException", because the |
|
| 1930 | // user is already assigned to the "Editors" group |
|
| 1931 | $userService->assignUserToUserGroup( |
|
| 1932 | $user, |
|
| 1933 | $userService->loadUserGroup($editorsGroupId) |
|
| 1934 | ); |
|
| 1935 | /* END: Use Case */ |
|
| 1936 | } |
|
| 1937 | ||
| 1938 | /** |
|
| 1939 | * Test for the unAssignUssrFromUserGroup() method. |
|