|
@@ 302-333 (lines=32) @@
|
| 299 |
|
* @see \eZ\Publish\API\Repository\RoleService::createRole() |
| 300 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\LimitationValidationException |
| 301 |
|
*/ |
| 302 |
|
public function testCreateRoleThrowsLimitationValidationException() |
| 303 |
|
{ |
| 304 |
|
$repository = $this->getRepository(); |
| 305 |
|
|
| 306 |
|
/* BEGIN: Use Case */ |
| 307 |
|
$roleService = $repository->getRoleService(); |
| 308 |
|
|
| 309 |
|
// Create new role create struct |
| 310 |
|
$roleCreate = $roleService->newRoleCreateStruct('Lumberjack'); |
| 311 |
|
|
| 312 |
|
// @todo uncomment when support for multilingual names and descriptions is added EZP-24776 |
| 313 |
|
// $roleCreate->mainLanguageCode = 'eng-US'; |
| 314 |
|
|
| 315 |
|
// Create new subtree limitation |
| 316 |
|
$limitation = new SubtreeLimitation( |
| 317 |
|
array( |
| 318 |
|
'limitationValues' => array('/mountain/forest/tree/42/'), |
| 319 |
|
) |
| 320 |
|
); |
| 321 |
|
|
| 322 |
|
// Create policy create struct and add limitation to it |
| 323 |
|
$policyCreate = $roleService->newPolicyCreateStruct('content', 'remove'); |
| 324 |
|
$policyCreate->addLimitation($limitation); |
| 325 |
|
|
| 326 |
|
// Add policy create struct to role create struct |
| 327 |
|
$roleCreate->addPolicy($policyCreate); |
| 328 |
|
|
| 329 |
|
// This call will fail with an LimitationValidationException, because subtree |
| 330 |
|
// "/mountain/forest/tree/42/" does not exist |
| 331 |
|
$roleService->createRole($roleCreate); |
| 332 |
|
/* END: Use Case */ |
| 333 |
|
} |
| 334 |
|
|
| 335 |
|
/** |
| 336 |
|
* Test for the createRole() method. |
|
@@ 1198-1227 (lines=30) @@
|
| 1195 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testNewPolicyCreateStruct |
| 1196 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testCreateRoleDraft |
| 1197 |
|
*/ |
| 1198 |
|
public function testAddPolicyByRoleDraftThrowsLimitationValidationException() |
| 1199 |
|
{ |
| 1200 |
|
$repository = $this->getRepository(); |
| 1201 |
|
|
| 1202 |
|
/* BEGIN: Use Case */ |
| 1203 |
|
$roleService = $repository->getRoleService(); |
| 1204 |
|
|
| 1205 |
|
$roleCreate = $roleService->newRoleCreateStruct('Lumberjack'); |
| 1206 |
|
|
| 1207 |
|
// @todo uncomment when support for multilingual names and descriptions is added EZP-24776 |
| 1208 |
|
// $roleCreate->mainLanguageCode = 'eng-US'; |
| 1209 |
|
|
| 1210 |
|
$roleDraft = $roleService->createRole($roleCreate); |
| 1211 |
|
|
| 1212 |
|
// Create new subtree limitation |
| 1213 |
|
$limitation = new SubtreeLimitation( |
| 1214 |
|
array( |
| 1215 |
|
'limitationValues' => array('/mountain/forest/tree/42/'), |
| 1216 |
|
) |
| 1217 |
|
); |
| 1218 |
|
|
| 1219 |
|
// Create policy create struct and add limitation to it |
| 1220 |
|
$policyCreateStruct = $roleService->newPolicyCreateStruct('content', 'remove'); |
| 1221 |
|
$policyCreateStruct->addLimitation($limitation); |
| 1222 |
|
|
| 1223 |
|
// This call will fail with an LimitationValidationException, because subtree |
| 1224 |
|
// "/mountain/forest/tree/42/" does not exist |
| 1225 |
|
$roleService->addPolicyByRoleDraft($roleDraft, $policyCreateStruct); |
| 1226 |
|
/* END: Use Case */ |
| 1227 |
|
} |
| 1228 |
|
|
| 1229 |
|
/** |
| 1230 |
|
* Test for the createRole() method. |