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:
Complex classes like PermissionTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use PermissionTest, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 28 | class PermissionTest extends BaseServiceMockTest |
||
| 29 | { |
||
| 30 | public function providerForTestHasAccessReturnsTrue() |
||
| 31 | { |
||
| 32 | return [ |
||
| 33 | [ |
||
| 34 | [ |
||
| 35 | 25 => $this->createRole( |
||
| 36 | [ |
||
| 37 | ['dummy-module', 'dummy-function', 'dummy-limitation'], |
||
| 38 | ['dummy-module2', 'dummy-function2', 'dummy-limitation2'], |
||
| 39 | ], |
||
| 40 | 25 |
||
| 41 | ), |
||
| 42 | 26 => $this->createRole( |
||
| 43 | [ |
||
| 44 | ['*', 'dummy-function', 'dummy-limitation'], |
||
| 45 | ], |
||
| 46 | 26 |
||
| 47 | ), |
||
| 48 | ], |
||
| 49 | [ |
||
| 50 | new RoleAssignment( |
||
| 51 | [ |
||
| 52 | 'roleId' => 25, |
||
| 53 | ] |
||
| 54 | ), |
||
| 55 | new RoleAssignment( |
||
| 56 | [ |
||
| 57 | 'roleId' => 26, |
||
| 58 | ] |
||
| 59 | ), |
||
| 60 | ], |
||
| 61 | ], |
||
| 62 | [ |
||
| 63 | [ |
||
| 64 | 27 => $this->createRole( |
||
| 65 | [ |
||
| 66 | ['dummy-module', '*', 'dummy-limitation'], |
||
| 67 | ], |
||
| 68 | 27 |
||
| 69 | ), |
||
| 70 | ], |
||
| 71 | [ |
||
| 72 | new RoleAssignment( |
||
| 73 | [ |
||
| 74 | 'roleId' => 27, |
||
| 75 | ] |
||
| 76 | ), |
||
| 77 | ], |
||
| 78 | ], |
||
| 79 | [ |
||
| 80 | [ |
||
| 81 | 28 => $this->createRole( |
||
| 82 | [ |
||
| 83 | ['dummy-module', 'dummy-function', '*'], |
||
| 84 | ], |
||
| 85 | 28 |
||
| 86 | ), |
||
| 87 | ], |
||
| 88 | [ |
||
| 89 | new RoleAssignment( |
||
| 90 | [ |
||
| 91 | 'roleId' => 28, |
||
| 92 | ] |
||
| 93 | ), |
||
| 94 | ], |
||
| 95 | ], |
||
| 96 | ]; |
||
| 97 | } |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Test for the hasAccess() method. |
||
| 101 | * |
||
| 102 | * @dataProvider providerForTestHasAccessReturnsTrue |
||
| 103 | */ |
||
| 104 | View Code Duplication | public function testHasAccessReturnsTrue(array $roles, array $roleAssignments) |
|
| 105 | { |
||
| 106 | /** @var $userHandlerMock \PHPUnit\Framework\MockObject\MockObject */ |
||
| 107 | $userHandlerMock = $this->getPersistenceMock()->userHandler(); |
||
| 108 | $userReferenceMock = $this->getUserReferenceMock(); |
||
| 109 | $mockedService = $this->getPermissionResolverMock(null); |
||
| 110 | |||
| 111 | $userReferenceMock |
||
| 112 | ->expects($this->once()) |
||
| 113 | ->method('getUserId') |
||
| 114 | ->will($this->returnValue(10)); |
||
| 115 | |||
| 116 | $userHandlerMock |
||
| 117 | ->expects($this->once()) |
||
| 118 | ->method('loadRoleAssignmentsByGroupId') |
||
| 119 | ->with($this->equalTo(10), $this->equalTo(true)) |
||
| 120 | ->will($this->returnValue($roleAssignments)); |
||
| 121 | |||
| 122 | foreach ($roleAssignments as $at => $roleAssignment) { |
||
| 123 | $userHandlerMock |
||
| 124 | ->expects($this->at($at + 1)) |
||
| 125 | ->method('loadRole') |
||
| 126 | ->with($roleAssignment->roleId) |
||
| 127 | ->will($this->returnValue($roles[$roleAssignment->roleId])); |
||
| 128 | } |
||
| 129 | |||
| 130 | $result = $mockedService->hasAccess('dummy-module', 'dummy-function'); |
||
| 131 | |||
| 132 | self::assertTrue($result); |
||
| 133 | } |
||
| 134 | |||
| 135 | public function providerForTestHasAccessReturnsFalse() |
||
| 136 | { |
||
| 137 | return [ |
||
| 138 | [[], []], |
||
| 139 | [ |
||
| 140 | [ |
||
| 141 | 29 => $this->createRole( |
||
| 142 | [ |
||
| 143 | ['dummy-module', 'dummy-function', 'dummy-limitation'], |
||
| 144 | ], |
||
| 145 | 29 |
||
| 146 | ), |
||
| 147 | ], |
||
| 148 | [ |
||
| 149 | new RoleAssignment( |
||
| 150 | [ |
||
| 151 | 'roleId' => 29, |
||
| 152 | ] |
||
| 153 | ), |
||
| 154 | ], |
||
| 155 | ], |
||
| 156 | [ |
||
| 157 | [ |
||
| 158 | 30 => $this->createRole( |
||
| 159 | [ |
||
| 160 | ['dummy-module', '*', 'dummy-limitation'], |
||
| 161 | ], |
||
| 162 | 30 |
||
| 163 | ), |
||
| 164 | ], |
||
| 165 | [ |
||
| 166 | new RoleAssignment( |
||
| 167 | [ |
||
| 168 | 'roleId' => 30, |
||
| 169 | ] |
||
| 170 | ), |
||
| 171 | ], |
||
| 172 | ], |
||
| 173 | ]; |
||
| 174 | } |
||
| 175 | |||
| 176 | /** |
||
| 177 | * Test for the hasAccess() method. |
||
| 178 | * |
||
| 179 | * @dataProvider providerForTestHasAccessReturnsFalse |
||
| 180 | */ |
||
| 181 | View Code Duplication | public function testHasAccessReturnsFalse(array $roles, array $roleAssignments) |
|
| 182 | { |
||
| 183 | /** @var $userHandlerMock \PHPUnit\Framework\MockObject\MockObject */ |
||
| 184 | $userHandlerMock = $this->getPersistenceMock()->userHandler(); |
||
| 185 | $userReferenceMock = $this->getUserReferenceMock(); |
||
| 186 | $service = $this->getPermissionResolverMock(null); |
||
| 187 | |||
| 188 | $userReferenceMock |
||
| 189 | ->expects($this->once()) |
||
| 190 | ->method('getUserId') |
||
| 191 | ->will($this->returnValue(10)); |
||
| 192 | |||
| 193 | $userHandlerMock |
||
| 194 | ->expects($this->once()) |
||
| 195 | ->method('loadRoleAssignmentsByGroupId') |
||
| 196 | ->with($this->equalTo(10), $this->equalTo(true)) |
||
| 197 | ->will($this->returnValue($roleAssignments)); |
||
| 198 | |||
| 199 | foreach ($roleAssignments as $at => $roleAssignment) { |
||
| 200 | $userHandlerMock |
||
| 201 | ->expects($this->at($at + 1)) |
||
| 202 | ->method('loadRole') |
||
| 203 | ->with($roleAssignment->roleId) |
||
| 204 | ->will($this->returnValue($roles[$roleAssignment->roleId])); |
||
| 205 | } |
||
| 206 | |||
| 207 | $result = $service->hasAccess('dummy-module2', 'dummy-function2'); |
||
| 208 | |||
| 209 | self::assertFalse($result); |
||
| 210 | } |
||
| 211 | |||
| 212 | /** |
||
| 213 | * Test for the sudo() & hasAccess() method. |
||
| 214 | */ |
||
| 215 | public function testHasAccessReturnsFalseButSudoSoTrue() |
||
| 216 | { |
||
| 217 | /** @var $userHandlerMock \PHPUnit\Framework\MockObject\MockObject */ |
||
| 218 | $userHandlerMock = $this->getPersistenceMock()->userHandler(); |
||
| 219 | $service = $this->getPermissionResolverMock(null); |
||
| 220 | $repositoryMock = $this->getRepositoryMock(); |
||
| 221 | $repositoryMock |
||
| 222 | ->expects($this->any()) |
||
| 223 | ->method('getPermissionResolver') |
||
| 224 | ->will($this->returnValue($service)); |
||
| 225 | |||
| 226 | $userHandlerMock |
||
| 227 | ->expects($this->never()) |
||
| 228 | ->method($this->anything()); |
||
| 229 | |||
| 230 | $result = $service->sudo( |
||
| 231 | function (Repository $repo) { |
||
| 232 | return $repo->getPermissionResolver()->hasAccess('dummy-module', 'dummy-function'); |
||
| 233 | }, |
||
| 234 | $repositoryMock |
||
| 235 | ); |
||
| 236 | |||
| 237 | self::assertTrue($result); |
||
| 238 | } |
||
| 239 | |||
| 240 | /** |
||
| 241 | * @return array |
||
| 242 | */ |
||
| 243 | View Code Duplication | public function providerForTestHasAccessReturnsPermissionSets() |
|
| 244 | { |
||
| 245 | return [ |
||
| 246 | [ |
||
| 247 | [ |
||
| 248 | 31 => $this->createRole( |
||
| 249 | [ |
||
| 250 | ['dummy-module', 'dummy-function', 'test-limitation'], |
||
| 251 | ], |
||
| 252 | 31 |
||
| 253 | ), |
||
| 254 | ], |
||
| 255 | [ |
||
| 256 | new RoleAssignment( |
||
| 257 | [ |
||
| 258 | 'roleId' => 31, |
||
| 259 | ] |
||
| 260 | ), |
||
| 261 | ], |
||
| 262 | ], |
||
| 263 | [ |
||
| 264 | [ |
||
| 265 | 31 => $this->createRole( |
||
| 266 | [ |
||
| 267 | ['dummy-module', 'dummy-function', 'test-limitation'], |
||
| 268 | ], |
||
| 269 | 31 |
||
| 270 | ), |
||
| 271 | 32 => $this->createRole( |
||
| 272 | [ |
||
| 273 | ['dummy-module', 'dummy-function', 'test-limitation2'], |
||
| 274 | ], |
||
| 275 | 32 |
||
| 276 | ), |
||
| 277 | ], |
||
| 278 | [ |
||
| 279 | new RoleAssignment( |
||
| 280 | [ |
||
| 281 | 'roleId' => 31, |
||
| 282 | ] |
||
| 283 | ), |
||
| 284 | new RoleAssignment( |
||
| 285 | [ |
||
| 286 | 'roleId' => 32, |
||
| 287 | ] |
||
| 288 | ), |
||
| 289 | ], |
||
| 290 | ], |
||
| 291 | ]; |
||
| 292 | } |
||
| 293 | |||
| 294 | /** |
||
| 295 | * Test for the hasAccess() method. |
||
| 296 | * |
||
| 297 | * @dataProvider providerForTestHasAccessReturnsPermissionSets |
||
| 298 | */ |
||
| 299 | public function testHasAccessReturnsPermissionSets(array $roles, array $roleAssignments) |
||
| 300 | { |
||
| 301 | /** @var $userHandlerMock \PHPUnit\Framework\MockObject\MockObject */ |
||
| 302 | $userHandlerMock = $this->getPersistenceMock()->userHandler(); |
||
| 303 | $roleDomainMapper = $this->getRoleDomainMapperMock(['buildDomainPolicyObject']); |
||
| 304 | $permissionResolverMock = $this->getPermissionResolverMock(['getCurrentUserReference']); |
||
| 305 | |||
| 306 | $permissionResolverMock |
||
| 307 | ->expects($this->once()) |
||
| 308 | ->method('getCurrentUserReference') |
||
| 309 | ->will($this->returnValue(new UserReference(14))); |
||
| 310 | |||
| 311 | $userHandlerMock |
||
| 312 | ->expects($this->once()) |
||
| 313 | ->method('loadRoleAssignmentsByGroupId') |
||
| 314 | ->with($this->isType('integer'), $this->equalTo(true)) |
||
| 315 | ->will($this->returnValue($roleAssignments)); |
||
| 316 | |||
| 317 | foreach ($roleAssignments as $at => $roleAssignment) { |
||
| 318 | $userHandlerMock |
||
| 319 | ->expects($this->at($at + 1)) |
||
| 320 | ->method('loadRole') |
||
| 321 | ->with($roleAssignment->roleId) |
||
| 322 | ->will($this->returnValue($roles[$roleAssignment->roleId])); |
||
| 323 | } |
||
| 324 | |||
| 325 | $permissionSets = []; |
||
| 326 | $count = 0; |
||
| 327 | /* @var $roleAssignments \eZ\Publish\SPI\Persistence\User\RoleAssignment[] */ |
||
| 328 | foreach ($roleAssignments as $i => $roleAssignment) { |
||
| 329 | $permissionSet = ['limitation' => null]; |
||
| 330 | foreach ($roles[$roleAssignment->roleId]->policies as $k => $policy) { |
||
| 331 | $policyName = 'policy-' . $i . '-' . $k; |
||
| 332 | $return = $this->returnValue($policyName); |
||
| 333 | $permissionSet['policies'][] = $policyName; |
||
| 334 | |||
| 335 | $roleDomainMapper |
||
| 336 | ->expects($this->at($count++)) |
||
| 337 | ->method('buildDomainPolicyObject') |
||
| 338 | ->with($policy) |
||
| 339 | ->will($return); |
||
| 340 | } |
||
| 341 | |||
| 342 | if (!empty($permissionSet['policies'])) { |
||
| 343 | $permissionSets[] = $permissionSet; |
||
| 344 | } |
||
| 345 | } |
||
| 346 | |||
| 347 | /* @var $repositoryMock \eZ\Publish\Core\Repository\Repository */ |
||
| 348 | self::assertEquals( |
||
| 349 | $permissionSets, |
||
| 350 | $permissionResolverMock->hasAccess('dummy-module', 'dummy-function') |
||
| 351 | ); |
||
| 352 | } |
||
| 353 | |||
| 354 | /** |
||
| 355 | * @return array |
||
| 356 | */ |
||
| 357 | View Code Duplication | public function providerForTestHasAccessReturnsLimitationNotFoundException() |
|
| 358 | { |
||
| 359 | return [ |
||
| 360 | [ |
||
| 361 | [ |
||
| 362 | 31 => $this->createRole( |
||
| 363 | [ |
||
| 364 | ['dummy-module', 'dummy-function', 'notfound'], |
||
| 365 | ], |
||
| 366 | 31 |
||
| 367 | ), |
||
| 368 | ], |
||
| 369 | [ |
||
| 370 | new RoleAssignment( |
||
| 371 | [ |
||
| 372 | 'roleId' => 31, |
||
| 373 | ] |
||
| 374 | ), |
||
| 375 | ], |
||
| 376 | ], |
||
| 377 | [ |
||
| 378 | [ |
||
| 379 | 31 => $this->createRole( |
||
| 380 | [ |
||
| 381 | ['dummy-module', 'dummy-function', 'test-limitation'], |
||
| 382 | ], |
||
| 383 | 31 |
||
| 384 | ), |
||
| 385 | 32 => $this->createRole( |
||
| 386 | [ |
||
| 387 | ['dummy-module', 'dummy-function', 'notfound'], |
||
| 388 | ], |
||
| 389 | 32 |
||
| 390 | ), |
||
| 391 | ], |
||
| 392 | [ |
||
| 393 | new RoleAssignment( |
||
| 394 | [ |
||
| 395 | 'roleId' => 31, |
||
| 396 | ] |
||
| 397 | ), |
||
| 398 | new RoleAssignment( |
||
| 399 | [ |
||
| 400 | 'roleId' => 32, |
||
| 401 | ] |
||
| 402 | ), |
||
| 403 | ], |
||
| 404 | ], |
||
| 405 | ]; |
||
| 406 | } |
||
| 407 | |||
| 408 | /** |
||
| 409 | * Test for the hasAccess() method. |
||
| 410 | * |
||
| 411 | * @dataProvider providerForTestHasAccessReturnsLimitationNotFoundException |
||
| 412 | */ |
||
| 413 | public function testHasAccessReturnsLimitationNotFoundException(array $roles, array $roleAssignments) |
||
| 414 | { |
||
| 415 | $this->expectException(\eZ\Publish\Core\Base\Exceptions\NotFound\LimitationNotFoundException::class); |
||
| 416 | |||
| 417 | /** @var $userHandlerMock \PHPUnit\Framework\MockObject\MockObject */ |
||
| 418 | $userHandlerMock = $this->getPersistenceMock()->userHandler(); |
||
| 419 | $roleDomainMapper = $this->getRoleDomainMapperMock(); |
||
| 420 | $permissionResolverMock = $this->getPermissionResolverMock(['getCurrentUserReference']); |
||
| 421 | |||
| 422 | $permissionResolverMock |
||
| 423 | ->expects($this->once()) |
||
| 424 | ->method('getCurrentUserReference') |
||
| 425 | ->will($this->returnValue(new UserReference(14))); |
||
| 426 | |||
| 427 | $userHandlerMock |
||
| 428 | ->expects($this->once()) |
||
| 429 | ->method('loadRoleAssignmentsByGroupId') |
||
| 430 | ->with($this->isType('integer'), $this->equalTo(true)) |
||
| 431 | ->will($this->returnValue($roleAssignments)); |
||
| 432 | |||
| 433 | foreach ($roleAssignments as $at => $roleAssignment) { |
||
| 434 | $userHandlerMock |
||
| 435 | ->expects($this->at($at + 1)) |
||
| 436 | ->method('loadRole') |
||
| 437 | ->with($roleAssignment->roleId) |
||
| 438 | ->will($this->returnValue($roles[$roleAssignment->roleId])); |
||
| 439 | } |
||
| 440 | |||
| 441 | $count = 0; |
||
| 442 | /* @var $roleAssignments \eZ\Publish\SPI\Persistence\User\RoleAssignment[] */ |
||
| 443 | foreach ($roleAssignments as $i => $roleAssignment) { |
||
| 444 | $permissionSet = ['limitation' => null]; |
||
| 445 | foreach ($roles[$roleAssignment->roleId]->policies as $k => $policy) { |
||
| 446 | $policyName = 'policy-' . $i . '-' . $k; |
||
| 447 | if ($policy->limitations === 'notfound') { |
||
| 448 | $return = $this->throwException(new LimitationNotFoundException('notfound')); |
||
| 449 | } else { |
||
| 450 | $return = $this->returnValue($policyName); |
||
| 451 | $permissionSet['policies'][] = $policyName; |
||
| 452 | } |
||
| 453 | |||
| 454 | $roleDomainMapper |
||
| 455 | ->expects($this->at($count++)) |
||
| 456 | ->method('buildDomainPolicyObject') |
||
| 457 | ->with($policy) |
||
| 458 | ->will($return); |
||
| 459 | |||
| 460 | if ($policy->limitations === 'notfound') { |
||
| 461 | break 2; // no more execution after exception |
||
| 462 | } |
||
| 463 | } |
||
| 464 | } |
||
| 465 | |||
| 466 | $permissionResolverMock->hasAccess('dummy-module', 'dummy-function'); |
||
| 467 | } |
||
| 468 | |||
| 469 | /** |
||
| 470 | * @return array |
||
| 471 | */ |
||
| 472 | View Code Duplication | public function providerForTestHasAccessReturnsInvalidArgumentValueException() |
|
| 522 | |||
| 523 | /** |
||
| 524 | * Test for the hasAccess() method. |
||
| 525 | * |
||
| 526 | * @dataProvider providerForTestHasAccessReturnsInvalidArgumentValueException |
||
| 527 | */ |
||
| 528 | public function testHasAccessReturnsInvalidArgumentValueException(array $roles, array $roleAssignments) |
||
| 529 | { |
||
| 530 | $this->expectException(\eZ\Publish\Core\Base\Exceptions\InvalidArgumentValue::class); |
||
| 531 | |||
| 542 | |||
| 543 | public function providerForTestHasAccessReturnsPermissionSetsWithRoleLimitation() |
||
| 587 | |||
| 588 | /** |
||
| 589 | * Test for the hasAccess() method. |
||
| 590 | * |
||
| 591 | * @dataProvider providerForTestHasAccessReturnsPermissionSetsWithRoleLimitation |
||
| 592 | */ |
||
| 593 | public function testHasAccessReturnsPermissionSetsWithRoleLimitation(array $roles, array $roleAssignments) |
||
| 655 | |||
| 656 | /** |
||
| 657 | * Returns Role stub. |
||
| 658 | * |
||
| 659 | * @param array $policiesData |
||
| 660 | * @param mixed $roleId |
||
| 661 | * |
||
| 662 | * @return \eZ\Publish\SPI\Persistence\User\Role |
||
| 663 | */ |
||
| 664 | private function createRole(array $policiesData, $roleId = null) |
||
| 684 | |||
| 685 | View Code Duplication | public function providerForTestCanUserSimple() |
|
| 693 | |||
| 694 | /** |
||
| 695 | * Test for the canUser() method. |
||
| 696 | * |
||
| 697 | * Tests execution paths with permission sets equaling to boolean value or empty array. |
||
| 698 | * |
||
| 699 | * @dataProvider providerForTestCanUserSimple |
||
| 700 | */ |
||
| 701 | View Code Duplication | public function testCanUserSimple($permissionSets, $result) |
|
| 719 | |||
| 720 | /** |
||
| 721 | * Test for the canUser() method. |
||
| 722 | * |
||
| 723 | * Tests execution path with permission set defining no limitations. |
||
| 724 | */ |
||
| 725 | public function testCanUserWithoutLimitations() |
||
| 773 | |||
| 774 | /** |
||
| 775 | * @return array |
||
| 776 | */ |
||
| 777 | private function getPermissionSetsMock() |
||
| 809 | |||
| 810 | /** |
||
| 811 | * Provides evaluation results for two permission sets, each with a role limitation and two policies, |
||
| 812 | * with two limitations per policy. |
||
| 813 | * |
||
| 814 | * @return array |
||
| 815 | */ |
||
| 816 | public function providerForTestCanUserComplex() |
||
| 891 | |||
| 892 | /** |
||
| 893 | * Test for the canUser() method. |
||
| 894 | * |
||
| 895 | * Tests execution paths with permission sets containing limitations. |
||
| 896 | * |
||
| 897 | * @dataProvider providerForTestCanUserComplex |
||
| 898 | */ |
||
| 899 | public function testCanUserComplex(array $roleLimitationEvaluations, array $policyLimitationEvaluations, $userCan) |
||
| 983 | |||
| 984 | /** |
||
| 985 | * Test for the setCurrentUserReference() and getCurrentUserReference() methods. |
||
| 986 | */ |
||
| 987 | public function testSetAndGetCurrentUserReference() |
||
| 1004 | |||
| 1005 | /** |
||
| 1006 | * Test for the getCurrentUserReference() method. |
||
| 1007 | */ |
||
| 1008 | public function testGetCurrentUserReferenceReturnsAnonymousUser() |
||
| 1018 | |||
| 1019 | protected $permissionResolverMock; |
||
| 1020 | |||
| 1021 | /** |
||
| 1022 | * @return \eZ\Publish\API\Repository\PermissionResolver|\PHPUnit\Framework\MockObject\MockObject |
||
| 1023 | */ |
||
| 1024 | protected function getPermissionResolverMock($methods = []) |
||
| 1061 | |||
| 1062 | protected $userReferenceMock; |
||
| 1063 | |||
| 1064 | protected function getUserReferenceMock() |
||
| 1072 | |||
| 1073 | protected $repositoryMock; |
||
| 1074 | |||
| 1075 | /** |
||
| 1076 | * @return \eZ\Publish\API\Repository\Repository|\PHPUnit\Framework\MockObject\MockObject |
||
| 1077 | */ |
||
| 1078 | protected function getRepositoryMock($methods = []) |
||
| 1090 | |||
| 1091 | protected $roleDomainMapperMock; |
||
| 1092 | |||
| 1093 | /** |
||
| 1094 | * @return \eZ\Publish\Core\Repository\Helper\RoleDomainMapper|\PHPUnit\Framework\MockObject\MockObject |
||
| 1095 | */ |
||
| 1096 | View Code Duplication | protected function getRoleDomainMapperMock($methods = []) |
|
| 1108 | } |
||
| 1109 |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: