Code Duplication    Length = 16-19 lines in 2 locations

eZ/Publish/Core/Repository/Tests/Service/Mock/RepositoryTest.php 2 locations

@@ 332-347 (lines=16) @@
329
        $count = 0;
330
        foreach ($roleAssignments as $i => $roleAssignment) {
331
            $permissionSet = array('limitation' => null);
332
            foreach ($roles[$roleAssignment->roleId]->policies as $k => $policy) {
333
                $policyName = 'policy-' . $i . '-' . $k;
334
                if ($policy->limitations === 'notfound') {
335
                    $return = $this->throwException(new LimitationNotFoundException('notfound'));
336
                    $this->setExpectedException('eZ\Publish\Core\Base\Exceptions\NotFound\LimitationNotFoundException');
337
                } else {
338
                    $return = $this->returnValue($policyName);
339
                    $permissionSet['policies'][] = $policyName;
340
                }
341
342
                $roleDomainMapper
343
                    ->expects($this->at($count++))
344
                    ->method('buildDomainPolicyObject')
345
                    ->with($policy)
346
                    ->will($return);
347
            }
348
            if (!empty($permissionSet['policies'])) {
349
                $permissionSets[] = $permissionSet;
350
            }
@@ 469-487 (lines=19) @@
466
        $count = 0;
467
        foreach ($roleAssignments as $i => $roleAssignment) {
468
            $permissionSet = array('limitation' => null);
469
            foreach ($roles[$roleAssignment->roleId]->policies as $k => $policy) {
470
                $policyName = 'policy-' . $i . '-' . $k;
471
                if ($policy->limitations === 'notfound') {
472
                    $return = $this->throwException(new LimitationNotFoundException('notfound'));
473
                } else {
474
                    $return = $this->returnValue($policyName);
475
                    $permissionSet['policies'][] = $policyName;
476
                }
477
478
                $roleDomainMapper
479
                    ->expects($this->at($count++))
480
                    ->method('buildDomainPolicyObject')
481
                    ->with($policy)
482
                    ->will($return);
483
484
                if ($policy->limitations === 'notfound') {
485
                    break 2;// no more execution after exception
486
                }
487
            }
488
        }
489
490
        /* @var $repositoryMock \eZ\Publish\Core\Repository\Repository */