Code Duplication    Length = 19-19 lines in 2 locations

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

@@ 2473-2491 (lines=19) @@
2470
     *
2471
     * @covers \eZ\Publish\API\Repository\RoleService::removeRoleAssignment
2472
     */
2473
    public function testUnassignRoleByAssignmentThrowsUnauthorizedException()
2474
    {
2475
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\UnauthorizedException::class);
2476
2477
        $repository = $this->getRepository();
2478
        $roleService = $repository->getRoleService();
2479
2480
        try {
2481
            $adminUserGroup = $repository->getUserService()->loadUserGroup(12);
2482
            $assignments = $roleService->getRoleAssignmentsForUserGroup($adminUserGroup);
2483
            $roleService->removeRoleAssignment($assignments[0]);
2484
        } catch (Exception $e) {
2485
            self::fail(
2486
                'Unexpected exception: ' . $e->getMessage() . " \n[" . $e->getFile() . ' (' . $e->getLine() . ')]'
2487
            );
2488
        }
2489
2490
        $roleService->removeRoleAssignment($assignments[0]);
2491
    }
2492
2493
    /**
2494
     * Test unassigning role by non-existing assignment.
@@ 2498-2516 (lines=19) @@
2495
     *
2496
     * @covers \eZ\Publish\API\Repository\RoleService::removeRoleAssignment
2497
     */
2498
    public function testUnassignRoleByAssignmentThrowsNotFoundException()
2499
    {
2500
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\NotFoundException::class);
2501
2502
        $repository = $this->getRepository();
2503
        $roleService = $repository->getRoleService();
2504
2505
        try {
2506
            $editorsUserGroup = $repository->getUserService()->loadUserGroup(13);
2507
            $assignments = $roleService->getRoleAssignmentsForUserGroup($editorsUserGroup);
2508
            $roleService->removeRoleAssignment($assignments[0]);
2509
        } catch (Exception $e) {
2510
            self::fail(
2511
                'Unexpected exception: ' . $e->getMessage() . " \n[" . $e->getFile() . ' (' . $e->getLine() . ')]'
2512
            );
2513
        }
2514
2515
        $roleService->removeRoleAssignment($assignments[0]);
2516
    }
2517
2518
    /**
2519
     * Test for the getRoleAssignmentsForUserGroup() method.