Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
20 | class RoleServiceAuthorizationTest extends BaseTest |
||
21 | { |
||
22 | /** |
||
23 | * Test for the createRole() method. |
||
24 | * |
||
25 | * @see \eZ\Publish\API\Repository\RoleService::createRole() |
||
26 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
27 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testCreateRole |
||
28 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
29 | */ |
||
30 | public function testCreateRoleThrowsUnauthorizedException() |
||
50 | |||
51 | /** |
||
52 | * Test for the loadRole() method. |
||
53 | * |
||
54 | * @see \eZ\Publish\API\Repository\RoleService::loadRole() |
||
55 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
56 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testLoadRole |
||
57 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
58 | */ |
||
59 | public function testLoadRoleThrowsUnauthorizedException() |
||
76 | |||
77 | /** |
||
78 | * Test for the loadRoleByIdentifier() method. |
||
79 | * |
||
80 | * @see \eZ\Publish\API\Repository\RoleService::loadRoleByIdentifier() |
||
81 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
82 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testLoadRoleByIdentifier |
||
83 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
84 | */ |
||
85 | public function testLoadRoleByIdentifierThrowsUnauthorizedException() |
||
102 | |||
103 | /** |
||
104 | * Test for the loadRoles() method. |
||
105 | * |
||
106 | * @see \eZ\Publish\API\Repository\RoleService::loadRoles() |
||
107 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
108 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testLoadRoles |
||
109 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
110 | */ |
||
111 | public function testLoadRolesThrowsUnauthorizedException() |
||
128 | |||
129 | /** |
||
130 | * Test for the updateRole() method. |
||
131 | * |
||
132 | * @see \eZ\Publish\API\Repository\RoleService::updateRole() |
||
133 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
134 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testUpdateRole |
||
135 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
136 | */ |
||
137 | public function testUpdateRoleThrowsUnauthorizedException() |
||
160 | |||
161 | /** |
||
162 | * Test for the deleteRole() method. |
||
163 | * |
||
164 | * @see \eZ\Publish\API\Repository\RoleService::deleteRole() |
||
165 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
166 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testDeleteRole |
||
167 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
168 | */ |
||
169 | public function testDeleteRoleThrowsUnauthorizedException() |
||
186 | |||
187 | /** |
||
188 | * Test for the addPolicy() method. |
||
189 | * |
||
190 | * @see \eZ\Publish\API\Repository\RoleService::addPolicy() |
||
191 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
192 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testAddPolicy |
||
193 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
194 | */ |
||
195 | public function testAddPolicyThrowsUnauthorizedException() |
||
215 | |||
216 | /** |
||
217 | * Test for the updatePolicy() method. |
||
218 | * |
||
219 | * @see \eZ\Publish\API\Repository\RoleService::updatePolicy() |
||
220 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
221 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testUpdatePolicy |
||
222 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
223 | */ |
||
224 | View Code Duplication | public function testUpdatePolicyThrowsUnauthorizedException() |
|
255 | |||
256 | /** |
||
257 | * Test for the removePolicy() method. |
||
258 | * |
||
259 | * @see \eZ\Publish\API\Repository\RoleService::removePolicy() |
||
260 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
261 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testRemovePolicy |
||
262 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
263 | */ |
||
264 | View Code Duplication | public function testRemovePolicyThrowsUnauthorizedException() |
|
295 | |||
296 | /** |
||
297 | * Test for the deletePolicy() method. |
||
298 | * |
||
299 | * @see \eZ\Publish\API\Repository\RoleService::deletePolicy() |
||
300 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
301 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testDeletePolicy |
||
302 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
303 | */ |
||
304 | public function testDeletePolicyThrowsUnauthorizedException() |
||
325 | |||
326 | /** |
||
327 | * Test for the assignRoleToUserGroup() method. |
||
328 | * |
||
329 | * @see \eZ\Publish\API\Repository\RoleService::assignRoleToUserGroup() |
||
330 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
331 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testAssignRoleToUserGroup |
||
332 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
333 | */ |
||
334 | public function testAssignRoleToUserGroupThrowsUnauthorizedException() |
||
357 | |||
358 | /** |
||
359 | * Test for the assignRoleToUserGroup() method. |
||
360 | * |
||
361 | * @see \eZ\Publish\API\Repository\RoleService::assignRoleToUserGroup($role, $userGroup, $roleLimitation) |
||
362 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
363 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testAssignRoleToUserGroup |
||
364 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
365 | */ |
||
366 | View Code Duplication | public function testAssignRoleToUserGroupThrowsUnauthorizedExceptionWithRoleLimitationParameter() |
|
396 | |||
397 | /** |
||
398 | * Test for the unassignRoleFromUserGroup() method. |
||
399 | * |
||
400 | * @see \eZ\Publish\API\Repository\RoleService::unassignRoleFromUserGroup() |
||
401 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
402 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testUnassignRoleFromUserGroup |
||
403 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
404 | */ |
||
405 | public function testUnassignRoleFromUserGroupThrowsUnauthorizedException() |
||
431 | |||
432 | /** |
||
433 | * Test for the assignRoleToUser() method. |
||
434 | * |
||
435 | * @see \eZ\Publish\API\Repository\RoleService::assignRoleToUser() |
||
436 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
437 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testAssignRoleToUser |
||
438 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
439 | */ |
||
440 | public function testAssignRoleToUserThrowsUnauthorizedException() |
||
457 | |||
458 | /** |
||
459 | * Test for the assignRoleToUser() method. |
||
460 | * |
||
461 | * @see \eZ\Publish\API\Repository\RoleService::assignRoleToUser($role, $user, $roleLimitation) |
||
462 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
463 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testAssignRoleToUser |
||
464 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
465 | */ |
||
466 | public function testAssignRoleToUserThrowsUnauthorizedExceptionWithRoleLimitationParameter() |
||
490 | |||
491 | /** |
||
492 | * Test for the unassignRoleFromUser() method. |
||
493 | * |
||
494 | * @see \eZ\Publish\API\Repository\RoleService::unassignRoleFromUser() |
||
495 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
496 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testUnassignRoleFromUser |
||
497 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
498 | */ |
||
499 | public function testUnassignRoleFromUserThrowsUnauthorizedException() |
||
519 | |||
520 | /** |
||
521 | * Test for the getRoleAssignments() method. |
||
522 | * |
||
523 | * @see \eZ\Publish\API\Repository\RoleService::getRoleAssignments() |
||
524 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
525 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testGetRoleAssignments |
||
526 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
527 | */ |
||
528 | public function testGetRoleAssignmentsThrowsUnauthorizedException() |
||
545 | |||
546 | /** |
||
547 | * Test for the getRoleAssignmentsForUser() method. |
||
548 | * |
||
549 | * @see \eZ\Publish\API\Repository\RoleService::getRoleAssignmentsForUser() |
||
550 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
551 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testGetRoleAssignmentsForUser |
||
552 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
553 | */ |
||
554 | public function testGetRoleAssignmentsForUserThrowsUnauthorizedException() |
||
571 | |||
572 | /** |
||
573 | * Test for the getRoleAssignmentsForUserGroup() method. |
||
574 | * |
||
575 | * @see \eZ\Publish\API\Repository\RoleService::getRoleAssignmentsForUserGroup() |
||
576 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
577 | * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testGetRoleAssignmentsForUserGroup |
||
578 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser |
||
579 | */ |
||
580 | View Code Duplication | public function testGetRoleAssignmentsForUserGroupThrowsUnauthorizedException() |
|
603 | |||
604 | /** |
||
605 | * Create a role fixture in a variable named <b>$role</b>,. |
||
606 | * |
||
607 | * @return \eZ\Publish\API\Repository\Values\User\Role |
||
608 | */ |
||
609 | private function createRole() |
||
636 | } |
||
637 |
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.