| @@ 82-115 (lines=34) @@ | ||
| 79 | * @see \eZ\Publish\API\Repository\Values\User\Limitation\ParentContentTypeLimitation |
|
| 80 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 81 | */ |
|
| 82 | public function testParentContentTypeLimitationForbid() |
|
| 83 | { |
|
| 84 | $repository = $this->getRepository(); |
|
| 85 | ||
| 86 | $parentContentTypeId = $this->generateId('contentType', 20); |
|
| 87 | $contentTypeId = $this->generateId('contentType', 33); |
|
| 88 | /* BEGIN: Use Case */ |
|
| 89 | $user = $this->createUserVersion1(); |
|
| 90 | ||
| 91 | $roleService = $repository->getRoleService(); |
|
| 92 | ||
| 93 | $role = $roleService->loadRoleByIdentifier('Editor'); |
|
| 94 | ||
| 95 | $policyCreate = $roleService->newPolicyCreateStruct('content', 'create'); |
|
| 96 | $policyCreate->addLimitation( |
|
| 97 | new ParentContentTypeLimitation( |
|
| 98 | array('limitationValues' => array($parentContentTypeId)) |
|
| 99 | ) |
|
| 100 | ); |
|
| 101 | $policyCreate->addLimitation( |
|
| 102 | new ContentTypeLimitation( |
|
| 103 | array('limitationValues' => array($contentTypeId)) |
|
| 104 | ) |
|
| 105 | ); |
|
| 106 | ||
| 107 | $role = $roleService->addPolicy($role, $policyCreate); |
|
| 108 | ||
| 109 | $roleService->assignRoleToUser($role, $user); |
|
| 110 | ||
| 111 | $repository->setCurrentUser($user); |
|
| 112 | ||
| 113 | $this->createWikiPageDraft(); |
|
| 114 | /* END: Use Case */ |
|
| 115 | } |
|
| 116 | } |
|
| 117 | ||
| @@ 35-72 (lines=38) @@ | ||
| 32 | * |
|
| 33 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 34 | */ |
|
| 35 | public function testParentDepthLimitationForbid() |
|
| 36 | { |
|
| 37 | $repository = $this->getRepository(); |
|
| 38 | ||
| 39 | $contentTypeId = $this->generateId('contentType', 22); |
|
| 40 | /* BEGIN: Use Case */ |
|
| 41 | $user = $this->createUserVersion1(); |
|
| 42 | ||
| 43 | $roleService = $repository->getRoleService(); |
|
| 44 | ||
| 45 | $role = $roleService->loadRoleByIdentifier('Editor'); |
|
| 46 | ||
| 47 | $policyCreate = $roleService->newPolicyCreateStruct('content', 'create'); |
|
| 48 | $policyCreate->addLimitation( |
|
| 49 | new ParentDepthLimitation( |
|
| 50 | array('limitationValues' => array(3)) |
|
| 51 | ) |
|
| 52 | ); |
|
| 53 | $policyCreate->addLimitation( |
|
| 54 | new ContentTypeLimitation( |
|
| 55 | array('limitationValues' => array($contentTypeId)) |
|
| 56 | ) |
|
| 57 | ); |
|
| 58 | ||
| 59 | $role = $roleService->addPolicy($role, $policyCreate); |
|
| 60 | ||
| 61 | $roleService->assignRoleToUser($role, $user); |
|
| 62 | ||
| 63 | $repository->setCurrentUser($user); |
|
| 64 | ||
| 65 | $draft = $this->createWikiPageDraft(); |
|
| 66 | /* END: Use Case */ |
|
| 67 | ||
| 68 | $this->assertEquals( |
|
| 69 | 'An awesome wiki page', |
|
| 70 | $draft->getFieldValue('title')->text |
|
| 71 | ); |
|
| 72 | } |
|
| 73 | ||
| 74 | /** |
|
| 75 | * Tests a combination of ParentDepthLimitation and ContentTypeLimitation. |
|