Code Duplication    Length = 19-19 lines in 2 locations

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

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