| @@ 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. |
|
| @@ 1195-1211 (lines=17) @@ | ||
| 1192 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 1193 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testCreateRole |
|
| 1194 | */ |
|
| 1195 | public function testPublishEmptyRoleThrowsInvalidArgumentException() |
|
| 1196 | { |
|
| 1197 | $repository = $this->getRepository(); |
|
| 1198 | ||
| 1199 | /* BEGIN: Use Case */ |
|
| 1200 | $roleService = $repository->getRoleService(); |
|
| 1201 | ||
| 1202 | $roleCreate = $roleService->newRoleCreateStruct('Lumberjack'); |
|
| 1203 | ||
| 1204 | // @todo uncomment when support for multilingual names and descriptions is added EZP-24776 |
|
| 1205 | // $roleCreate->mainLanguageCode = 'eng-US'; |
|
| 1206 | ||
| 1207 | $roleDraft = $roleService->createRole($roleCreate); |
|
| 1208 | // This call will fail with an InvalidArgumentException, because the role has no policies |
|
| 1209 | $roleService->publishRoleDraft($roleDraft); |
|
| 1210 | /* END: Use Case */ |
|
| 1211 | } |
|
| 1212 | ||
| 1213 | /** |
|
| 1214 | * Test for the addPolicy() method. |
|