| @@ 86-105 (lines=20) @@ | ||
| 83 | * |
|
| 84 | * @return \eZ\Publish\API\Repository\Values\User\UserGroup |
|
| 85 | */ |
|
| 86 | protected function prepareUserGroup() |
|
| 87 | { |
|
| 88 | $repository = $this->getRepository(); |
|
| 89 | $userService = $repository->getUserService(); |
|
| 90 | ||
| 91 | $parentUserGroupId = $this->generateId('location', 4); |
|
| 92 | /* BEGIN: Inline */ |
|
| 93 | $userGroupCreate = $userService->newUserGroupCreateStruct('eng-GB'); |
|
| 94 | $userGroupCreate->setField('name', 'Shared wiki'); |
|
| 95 | ||
| 96 | $userGroup = $userService->createUserGroup( |
|
| 97 | $userGroupCreate, |
|
| 98 | $userService->loadUserGroup( |
|
| 99 | $parentUserGroupId |
|
| 100 | ) |
|
| 101 | ); |
|
| 102 | /* END: Inline */ |
|
| 103 | ||
| 104 | return $userGroup; |
|
| 105 | } |
|
| 106 | ||
| 107 | /** |
|
| 108 | * Prepares the limitation fixture. |
|
| @@ 387-407 (lines=21) @@ | ||
| 384 | * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
|
| 385 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUserGroup |
|
| 386 | */ |
|
| 387 | public function testCreateUserGroupWhenMissingField() |
|
| 388 | { |
|
| 389 | $repository = $this->getRepository(); |
|
| 390 | ||
| 391 | $mainGroupId = $this->generateId('group', 4); |
|
| 392 | /* BEGIN: Use Case */ |
|
| 393 | // $mainGroupId is the ID of the main "Users" group |
|
| 394 | ||
| 395 | $userService = $repository->getUserService(); |
|
| 396 | ||
| 397 | // Load main group |
|
| 398 | $parentUserGroup = $userService->loadUserGroup($mainGroupId); |
|
| 399 | ||
| 400 | // Instantiate a new create struct |
|
| 401 | $userGroupCreate = $userService->newUserGroupCreateStruct('eng-US'); |
|
| 402 | ||
| 403 | // This call will fail with a "ContentFieldValidationException", because the |
|
| 404 | // only mandatory field "name" is not set. |
|
| 405 | $userService->createUserGroup($userGroupCreate, $parentUserGroup); |
|
| 406 | /* END: Use Case */ |
|
| 407 | } |
|
| 408 | ||
| 409 | /** |
|
| 410 | * Test for the createUserGroup() method. |
|