| @@ 264-289 (lines=26) @@ | ||
| 261 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 262 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUserGroup |
|
| 263 | */ |
|
| 264 | public function testCreateUserGroupThrowsInvalidArgumentException() |
|
| 265 | { |
|
| 266 | $repository = $this->getRepository(); |
|
| 267 | ||
| 268 | $mainGroupId = $this->generateId('group', 4); |
|
| 269 | /* BEGIN: Use Case */ |
|
| 270 | // $mainGroupId is the ID of the main "Users" group |
|
| 271 | ||
| 272 | $userService = $repository->getUserService(); |
|
| 273 | ||
| 274 | // Load main group |
|
| 275 | $parentUserGroup = $userService->loadUserGroup($mainGroupId); |
|
| 276 | ||
| 277 | // Instantiate a new create struct |
|
| 278 | $userGroupCreate = $userService->newUserGroupCreateStruct('eng-US'); |
|
| 279 | $userGroupCreate->setField('name', 'Example Group'); |
|
| 280 | $userGroupCreate->remoteId = '5f7f0bdb3381d6a461d8c29ff53d908f'; |
|
| 281 | ||
| 282 | // This call will fail with an "InvalidArgumentException", because the |
|
| 283 | // specified remoteId is already used for the "Members" user group. |
|
| 284 | $userService->createUserGroup( |
|
| 285 | $userGroupCreate, |
|
| 286 | $parentUserGroup |
|
| 287 | ); |
|
| 288 | /* END: Use Case */ |
|
| 289 | } |
|
| 290 | ||
| 291 | /** |
|
| 292 | * Test for the createUserGroup() method. |
|
| @@ 858-888 (lines=31) @@ | ||
| 855 | * @expectedException \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException |
|
| 856 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
|
| 857 | */ |
|
| 858 | public function testCreateUserWhenMissingField() |
|
| 859 | { |
|
| 860 | $repository = $this->getRepository(); |
|
| 861 | ||
| 862 | $editorsGroupId = $this->generateId('group', 13); |
|
| 863 | /* BEGIN: Use Case */ |
|
| 864 | // $editorsGroupId is the ID of the "Editors" user group in an eZ |
|
| 865 | // Publish demo installation |
|
| 866 | ||
| 867 | $userService = $repository->getUserService(); |
|
| 868 | ||
| 869 | // Instantiate a create struct with mandatory properties |
|
| 870 | $userCreate = $userService->newUserCreateStruct( |
|
| 871 | 'user', |
|
| 872 | '[email protected]', |
|
| 873 | 'secret', |
|
| 874 | 'eng-US' |
|
| 875 | ); |
|
| 876 | ||
| 877 | // Do not set the mandatory fields "first_name" and "last_name" |
|
| 878 | //$userCreate->setField( 'first_name', 'Example' ); |
|
| 879 | //$userCreate->setField( 'last_name', 'User' ); |
|
| 880 | ||
| 881 | // Load parent group for the user |
|
| 882 | $group = $userService->loadUserGroup($editorsGroupId); |
|
| 883 | ||
| 884 | // This call will fail with a "ContentFieldValidationException", because the |
|
| 885 | // mandatory fields "first_name" and "last_name" are not set. |
|
| 886 | $userService->createUser($userCreate, array($group)); |
|
| 887 | /* END: Use Case */ |
|
| 888 | } |
|
| 889 | ||
| 890 | /** |
|
| 891 | * Test for the createUser() method. |
|
| @@ 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. |
|