Code Duplication    Length = 19-19 lines in 2 locations

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

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