Code Duplication    Length = 19-19 lines in 2 locations

eZ/Publish/API/Repository/Tests/RoleServiceTest.php 2 locations

@@ 2657-2675 (lines=19) @@
2654
     *
2655
     * @covers \eZ\Publish\API\Repository\RoleService::removeRoleAssignment
2656
     */
2657
    public function testUnassignRoleByAssignmentThrowsUnauthorizedException()
2658
    {
2659
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\UnauthorizedException::class);
2660
2661
        $repository = $this->getRepository();
2662
        $roleService = $repository->getRoleService();
2663
2664
        try {
2665
            $adminUserGroup = $repository->getUserService()->loadUserGroup(12);
2666
            $assignments = $roleService->getRoleAssignmentsForUserGroup($adminUserGroup);
2667
            $roleService->removeRoleAssignment($assignments[0]);
2668
        } catch (Exception $e) {
2669
            self::fail(
2670
                'Unexpected exception: ' . $e->getMessage() . " \n[" . $e->getFile() . ' (' . $e->getLine() . ')]'
2671
            );
2672
        }
2673
2674
        $roleService->removeRoleAssignment($assignments[0]);
2675
    }
2676
2677
    /**
2678
     * Test unassigning role by non-existing assignment.
@@ 2682-2700 (lines=19) @@
2679
     *
2680
     * @covers \eZ\Publish\API\Repository\RoleService::removeRoleAssignment
2681
     */
2682
    public function testUnassignRoleByAssignmentThrowsNotFoundException()
2683
    {
2684
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\NotFoundException::class);
2685
2686
        $repository = $this->getRepository();
2687
        $roleService = $repository->getRoleService();
2688
2689
        try {
2690
            $editorsUserGroup = $repository->getUserService()->loadUserGroup(13);
2691
            $assignments = $roleService->getRoleAssignmentsForUserGroup($editorsUserGroup);
2692
            $roleService->removeRoleAssignment($assignments[0]);
2693
        } catch (Exception $e) {
2694
            self::fail(
2695
                'Unexpected exception: ' . $e->getMessage() . " \n[" . $e->getFile() . ' (' . $e->getLine() . ')]'
2696
            );
2697
        }
2698
2699
        $roleService->removeRoleAssignment($assignments[0]);
2700
    }
2701
2702
    /**
2703
     * Test for the getRoleAssignmentsForUserGroup() method.