Code Duplication    Length = 19-19 lines in 2 locations

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

@@ 2610-2628 (lines=19) @@
2607
     *
2608
     * @covers \eZ\Publish\API\Repository\RoleService::removeRoleAssignment
2609
     */
2610
    public function testUnassignRoleByAssignmentThrowsUnauthorizedException()
2611
    {
2612
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\UnauthorizedException::class);
2613
2614
        $repository = $this->getRepository();
2615
        $roleService = $repository->getRoleService();
2616
2617
        try {
2618
            $adminUserGroup = $repository->getUserService()->loadUserGroup(12);
2619
            $assignments = $roleService->getRoleAssignmentsForUserGroup($adminUserGroup);
2620
            $roleService->removeRoleAssignment($assignments[0]);
2621
        } catch (Exception $e) {
2622
            self::fail(
2623
                'Unexpected exception: ' . $e->getMessage() . " \n[" . $e->getFile() . ' (' . $e->getLine() . ')]'
2624
            );
2625
        }
2626
2627
        $roleService->removeRoleAssignment($assignments[0]);
2628
    }
2629
2630
    /**
2631
     * Test unassigning role by non-existing assignment.
@@ 2635-2653 (lines=19) @@
2632
     *
2633
     * @covers \eZ\Publish\API\Repository\RoleService::removeRoleAssignment
2634
     */
2635
    public function testUnassignRoleByAssignmentThrowsNotFoundException()
2636
    {
2637
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\NotFoundException::class);
2638
2639
        $repository = $this->getRepository();
2640
        $roleService = $repository->getRoleService();
2641
2642
        try {
2643
            $editorsUserGroup = $repository->getUserService()->loadUserGroup(13);
2644
            $assignments = $roleService->getRoleAssignmentsForUserGroup($editorsUserGroup);
2645
            $roleService->removeRoleAssignment($assignments[0]);
2646
        } catch (Exception $e) {
2647
            self::fail(
2648
                'Unexpected exception: ' . $e->getMessage() . " \n[" . $e->getFile() . ' (' . $e->getLine() . ')]'
2649
            );
2650
        }
2651
2652
        $roleService->removeRoleAssignment($assignments[0]);
2653
    }
2654
2655
    /**
2656
     * Test for the getRoleAssignmentsForUserGroup() method.