|
@@ 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. |
|
@@ 1229-1258 (lines=30) @@
|
| 1226 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testNewPolicyCreateStruct |
| 1227 |
|
* @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testCreateRoleDraft |
| 1228 |
|
*/ |
| 1229 |
|
public function testAddPolicyByRoleDraftThrowsLimitationValidationException() |
| 1230 |
|
{ |
| 1231 |
|
$repository = $this->getRepository(); |
| 1232 |
|
|
| 1233 |
|
/* BEGIN: Use Case */ |
| 1234 |
|
$roleService = $repository->getRoleService(); |
| 1235 |
|
|
| 1236 |
|
$roleCreate = $roleService->newRoleCreateStruct('Lumberjack'); |
| 1237 |
|
|
| 1238 |
|
// @todo uncomment when support for multilingual names and descriptions is added EZP-24776 |
| 1239 |
|
// $roleCreate->mainLanguageCode = 'eng-US'; |
| 1240 |
|
|
| 1241 |
|
$roleDraft = $roleService->createRole($roleCreate); |
| 1242 |
|
|
| 1243 |
|
// Create new subtree limitation |
| 1244 |
|
$limitation = new SubtreeLimitation( |
| 1245 |
|
array( |
| 1246 |
|
'limitationValues' => array('/mountain/forest/tree/42/'), |
| 1247 |
|
) |
| 1248 |
|
); |
| 1249 |
|
|
| 1250 |
|
// Create policy create struct and add limitation to it |
| 1251 |
|
$policyCreateStruct = $roleService->newPolicyCreateStruct('content', 'remove'); |
| 1252 |
|
$policyCreateStruct->addLimitation($limitation); |
| 1253 |
|
|
| 1254 |
|
// This call will fail with an LimitationValidationException, because subtree |
| 1255 |
|
// "/mountain/forest/tree/42/" does not exist |
| 1256 |
|
$roleService->addPolicyByRoleDraft($roleDraft, $policyCreateStruct); |
| 1257 |
|
/* END: Use Case */ |
| 1258 |
|
} |
| 1259 |
|
|
| 1260 |
|
/** |
| 1261 |
|
* Test for the createRole() method. |