| @@ 30-49 (lines=20) @@ | ||
| 27 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testCreateRole |
|
| 28 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
|
| 29 | */ |
|
| 30 | public function testCreateRoleThrowsUnauthorizedException() |
|
| 31 | { |
|
| 32 | $repository = $this->getRepository(); |
|
| 33 | ||
| 34 | /* BEGIN: Use Case */ |
|
| 35 | $user = $this->createUserVersion1(); |
|
| 36 | ||
| 37 | // Set "Editor" user as current user. |
|
| 38 | $repository->setCurrentUser($user); |
|
| 39 | ||
| 40 | // Get the role service |
|
| 41 | $roleService = $repository->getRoleService(); |
|
| 42 | ||
| 43 | // Instantiate a role create struct. |
|
| 44 | $roleCreate = $roleService->newRoleCreateStruct('roleName'); |
|
| 45 | ||
| 46 | // This call will fail with an "UnauthorizedException" |
|
| 47 | $roleService->createRole($roleCreate); |
|
| 48 | /* END: Use Case */ |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * Test for the loadRole() method. |
|
| @@ 1157-1173 (lines=17) @@ | ||
| 1154 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testNewPolicyCreateStruct |
|
| 1155 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testCreateRole |
|
| 1156 | */ |
|
| 1157 | public function testPublishEmptyRoleThrowsInvalidArgumentException() |
|
| 1158 | { |
|
| 1159 | $repository = $this->getRepository(); |
|
| 1160 | ||
| 1161 | /* BEGIN: Use Case */ |
|
| 1162 | $roleService = $repository->getRoleService(); |
|
| 1163 | ||
| 1164 | $roleCreate = $roleService->newRoleCreateStruct('Lumberjack'); |
|
| 1165 | ||
| 1166 | // @todo uncomment when support for multilingual names and descriptions is added EZP-24776 |
|
| 1167 | // $roleCreate->mainLanguageCode = 'eng-US'; |
|
| 1168 | ||
| 1169 | $roleDraft = $roleService->createRole($roleCreate); |
|
| 1170 | // This call will fail with an InvalidArgumentException, because the role has no policies |
|
| 1171 | $roleService->publishRoleDraft($roleDraft); |
|
| 1172 | /* END: Use Case */ |
|
| 1173 | } |
|
| 1174 | ||
| 1175 | /** |
|
| 1176 | * Test for the addPolicy() method. |
|