Code Duplication    Length = 30-32 lines in 2 locations

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

@@ 1502-1533 (lines=32) @@
1499
     * @see \eZ\Publish\API\Repository\RoleService::removePolicyByRoleDraft()
1500
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testAddPolicyByRoleDraft
1501
     */
1502
    public function testRemovePolicyByRoleDraft()
1503
    {
1504
        $repository = $this->getRepository();
1505
1506
        /* BEGIN: Use Case */
1507
        $roleService = $repository->getRoleService();
1508
1509
        // Instantiate a new role create
1510
        $roleCreate = $roleService->newRoleCreateStruct('newRole');
1511
1512
        // @todo uncomment when support for multilingual names and descriptions is added EZP-24776
1513
        // $roleCreate->mainLanguageCode = 'eng-US';
1514
1515
        // Create a new role with two policies
1516
        $roleDraft = $roleService->createRole($roleCreate);
1517
        $roleService->addPolicyByRoleDraft(
1518
            $roleDraft,
1519
            $roleService->newPolicyCreateStruct('content', 'create')
1520
        );
1521
        $roleService->addPolicyByRoleDraft(
1522
            $roleDraft,
1523
            $roleService->newPolicyCreateStruct('content', 'delete')
1524
        );
1525
1526
        // Delete all policies from the new role
1527
        foreach ($roleDraft->getPolicies() as $policy) {
1528
            $roleDraft = $roleService->removePolicyByRoleDraft($roleDraft, $policy);
1529
        }
1530
        /* END: Use Case */
1531
1532
        $this->assertSame([], $roleDraft->getPolicies());
1533
    }
1534
1535
    /**
1536
     * Test for the addPolicyByRoleDraft() method.
@@ 2647-2676 (lines=30) @@
2644
     * @see \eZ\Publish\API\Repository\RoleService::publishRoleDraft()
2645
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testCreateRoleDraft
2646
     */
2647
    public function testPublishRoleDraft()
2648
    {
2649
        $repository = $this->getRepository();
2650
2651
        /* BEGIN: Use Case */
2652
        $roleService = $repository->getRoleService();
2653
        $roleCreate = $roleService->newRoleCreateStruct('newRole');
2654
2655
        // @todo uncomment when support for multilingual names and descriptions is added EZP-24776
2656
        // $roleCreate->mainLanguageCode = 'eng-US';
2657
2658
        $roleDraft = $roleService->createRole($roleCreate);
2659
2660
        $roleDraft = $roleService->addPolicyByRoleDraft(
2661
            $roleDraft,
2662
            $roleService->newPolicyCreateStruct('content', 'delete')
2663
        );
2664
        $roleDraft = $roleService->addPolicyByRoleDraft(
2665
            $roleDraft,
2666
            $roleService->newPolicyCreateStruct('content', 'create')
2667
        );
2668
2669
        $roleService->publishRoleDraft($roleDraft);
2670
        /* END: Use Case */
2671
2672
        $this->assertInstanceOf(
2673
            '\\eZ\\Publish\\API\\Repository\\Values\\User\\Role',
2674
            $roleService->loadRoleByIdentifier($roleCreate->identifier)
2675
        );
2676
    }
2677
2678
    /**
2679
     * Test for the publishRoleDraft() method.