1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the ParentDepthLimitationTest class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
* |
9
|
|
|
* @version //autogentag// |
10
|
|
|
*/ |
11
|
|
|
namespace eZ\Publish\API\Repository\Tests\Values\User\Limitation; |
12
|
|
|
|
13
|
|
|
use eZ\Publish\API\Repository\Values\User\Limitation\ContentTypeLimitation; |
14
|
|
|
use eZ\Publish\API\Repository\Values\User\Limitation\ParentDepthLimitation; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Test case for the {@link \eZ\Publish\API\Repository\Values\User\Limitation\ParentDepthLimitation} |
18
|
|
|
* class. |
19
|
|
|
* |
20
|
|
|
* @see eZ\Publish\API\Repository\Values\User\Limitation |
21
|
|
|
* @see eZ\Publish\API\Repository\Values\User\Limitation\ParentDepthLimitation |
22
|
|
|
* @group integration |
23
|
|
|
* @group limitation |
24
|
|
|
*/ |
25
|
|
|
class ParentDepthLimitationTest extends BaseLimitationTest |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* Tests a combination of ParentDepthLimitation and ContentTypeLimitation. |
29
|
|
|
* |
30
|
|
|
* @see \eZ\Publish\API\Repository\Values\User\Limitation\ContentTypeLimitation |
31
|
|
|
* @see \eZ\Publish\API\Repository\Values\User\Limitation\ParentDepthLimitation |
32
|
|
|
*/ |
33
|
|
View Code Duplication |
public function testParentDepthLimitationAllow() |
34
|
|
|
{ |
35
|
|
|
$repository = $this->getRepository(); |
36
|
|
|
|
37
|
|
|
$contentTypeId = $this->generateId('contentType', 22); |
38
|
|
|
/* BEGIN: Use Case */ |
39
|
|
|
$user = $this->createUserVersion1(); |
40
|
|
|
|
41
|
|
|
$roleService = $repository->getRoleService(); |
42
|
|
|
|
43
|
|
|
$role = $roleService->loadRoleByIdentifier('Editor'); |
44
|
|
|
|
45
|
|
|
$policyCreate = $roleService->newPolicyCreateStruct('content', 'create'); |
46
|
|
|
$policyCreate->addLimitation( |
47
|
|
|
new ParentDepthLimitation( |
48
|
|
|
array('limitationValues' => array(2)) |
49
|
|
|
) |
50
|
|
|
); |
51
|
|
|
$policyCreate->addLimitation( |
52
|
|
|
new ContentTypeLimitation( |
53
|
|
|
array('limitationValues' => array($contentTypeId)) |
54
|
|
|
) |
55
|
|
|
); |
56
|
|
|
|
57
|
|
|
$role = $roleService->addPolicy($role, $policyCreate); |
|
|
|
|
58
|
|
|
|
59
|
|
|
$roleService->assignRoleToUser($role, $user); |
60
|
|
|
|
61
|
|
|
$repository->setCurrentUser($user); |
62
|
|
|
|
63
|
|
|
$draft = $this->createWikiPageDraft(); |
64
|
|
|
/* END: Use Case */ |
65
|
|
|
|
66
|
|
|
$this->assertEquals( |
67
|
|
|
'An awesome wiki page', |
68
|
|
|
$draft->getFieldValue('title')->text |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Tests a combination of ParentDepthLimitation and ContentTypeLimitation. |
74
|
|
|
* |
75
|
|
|
* @see \eZ\Publish\API\Repository\Values\User\Limitation\ContentTypeLimitation |
76
|
|
|
* @see \eZ\Publish\API\Repository\Values\User\Limitation\ParentDepthLimitation |
77
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
78
|
|
|
*/ |
79
|
|
|
public function testParentDepthLimitationForbid() |
80
|
|
|
{ |
81
|
|
|
$repository = $this->getRepository(); |
82
|
|
|
|
83
|
|
|
$contentTypeId = $this->generateId('contentType', 22); |
84
|
|
|
/* BEGIN: Use Case */ |
85
|
|
|
$user = $this->createUserVersion1(); |
86
|
|
|
|
87
|
|
|
$roleService = $repository->getRoleService(); |
88
|
|
|
|
89
|
|
|
$role = $roleService->loadRoleByIdentifier('Editor'); |
90
|
|
|
|
91
|
|
|
$policyCreate = $roleService->newPolicyCreateStruct('content', 'create'); |
92
|
|
|
$policyCreate->addLimitation( |
93
|
|
|
new ParentDepthLimitation( |
94
|
|
|
array('limitationValues' => array(1, 3, 4)) |
95
|
|
|
) |
96
|
|
|
); |
97
|
|
|
$policyCreate->addLimitation( |
98
|
|
|
new ContentTypeLimitation( |
99
|
|
|
array('limitationValues' => array($contentTypeId)) |
100
|
|
|
) |
101
|
|
|
); |
102
|
|
|
|
103
|
|
|
$role = $roleService->addPolicy($role, $policyCreate); |
|
|
|
|
104
|
|
|
|
105
|
|
|
$roleService->assignRoleToUser($role, $user); |
106
|
|
|
|
107
|
|
|
$repository->setCurrentUser($user); |
108
|
|
|
|
109
|
|
|
$this->createWikiPageDraft(); |
110
|
|
|
/* END: Use Case */ |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.