Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
47 | public function testRolePoliciesWithOverlappingLimitations( |
||
48 | $expectedSubtreeLocationsCount, |
||
49 | $widePolicyModule, |
||
50 | $widePolicyFunction |
||
51 | ) { |
||
52 | $repository = $this->getRepository(); |
||
53 | $roleService = $repository->getRoleService(); |
||
54 | |||
55 | $subtreePathString = '/1/2/'; |
||
56 | |||
57 | // EZP-26476 use case: |
||
58 | |||
59 | // create new role with overlapping limitation |
||
60 | $roleName = 'role_with_overlapping_policies'; |
||
61 | $roleCreateStruct = $roleService->newRoleCreateStruct($roleName); |
||
62 | |||
63 | $this->addPolicyToNewRole($roleCreateStruct, $widePolicyModule, $widePolicyFunction, []); |
||
64 | $this->addPolicyToNewRole($roleCreateStruct, 'user', 'login', []); |
||
65 | $this->addPolicyToNewRole($roleCreateStruct, 'content', 'read', [ |
||
66 | new ContentTypeLimitation([ |
||
67 | 'limitationValues' => [4, 3], |
||
68 | ]), |
||
69 | new SectionLimitation([ |
||
70 | 'limitationValues' => [2], |
||
71 | ]), |
||
72 | ]); |
||
73 | |||
74 | $roleService->publishRoleDraft( |
||
75 | $roleService->createRole($roleCreateStruct) |
||
76 | ); |
||
77 | |||
78 | $role = $roleService->loadRoleByIdentifier($roleName); |
||
79 | |||
80 | // create group and assign new role to that group, limited by subtree |
||
81 | $userGroup = $this->createGroup('Test group', 'eng-US', 4); |
||
82 | $roleService->assignRoleToUserGroup($role, $userGroup, new SubtreeLimitation([ |
||
83 | 'limitationValues' => [$subtreePathString], |
||
84 | ])); |
||
85 | |||
86 | // create user assigned to the just created group |
||
87 | $user = $this->createUserInGroup($userGroup); |
||
88 | $repository->setCurrentUser($user); |
||
|
|||
89 | |||
90 | $this->refreshSearch($repository); |
||
91 | |||
92 | // check if searching by subtree returns the same result as for an admin |
||
93 | $this->assertEquals($expectedSubtreeLocationsCount, $this->getSubtreeLocationsCount($subtreePathString)); |
||
94 | |||
95 | // check if searching by subtree which is not a part of role assignment limitation does not return results |
||
96 | $this->assertEquals(0, $this->getSubtreeLocationsCount('/1/5/')); |
||
97 | } |
||
98 | |||
181 |
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.