Code Duplication    Length = 22-24 lines in 2 locations

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

@@ 731-754 (lines=24) @@
728
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testNewRoleUpdateStruct
729
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testLoadRoleDraft
730
     */
731
    public function testUpdateRoleDraft()
732
    {
733
        $repository = $this->getRepository();
734
735
        /* BEGIN: Use Case */
736
        $roleService = $repository->getRoleService();
737
        $roleCreate = $roleService->newRoleCreateStruct('newRole');
738
739
        // @todo uncomment when support for multilingual names and descriptions is added EZP-24776
740
        // $roleCreate->mainLanguageCode = 'eng-US';
741
742
        $roleDraft = $roleService->createRole($roleCreate);
743
744
        $roleUpdate = $roleService->newRoleUpdateStruct();
745
        $roleUpdate->identifier = 'updatedRole';
746
747
        $updatedRole = $roleService->updateRoleDraft($roleDraft, $roleUpdate);
748
        /* END: Use Case */
749
750
        // Now verify that our change was saved
751
        $role = $roleService->loadRoleDraft($updatedRole->id);
752
753
        $this->assertEquals($role->identifier, 'updatedRole');
754
    }
755
756
    /**
757
     * Test for the updateRole() method.
@@ 763-784 (lines=22) @@
760
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
761
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testUpdateRole
762
     */
763
    public function testUpdateRoleThrowsInvalidArgumentException()
764
    {
765
        $repository = $this->getRepository();
766
767
        /* BEGIN: Use Case */
768
        $roleService = $repository->getRoleService();
769
        $roleCreate = $roleService->newRoleCreateStruct('newRole');
770
771
        // @todo uncomment when support for multilingual names and descriptions is added EZP-24776
772
        // $roleCreate->mainLanguageCode = 'eng-US';
773
774
        $roleDraft = $roleService->createRole($roleCreate);
775
        $roleService->publishRoleDraft($roleDraft);
776
        $role = $roleService->loadRole($roleDraft->id);
777
778
        $roleUpdate = $roleService->newRoleUpdateStruct();
779
        $roleUpdate->identifier = 'Editor';
780
781
        // This call will fail with an InvalidArgumentException, because Editor is a predefined role
782
        $roleService->updateRole($role, $roleUpdate);
783
        /* END: Use Case */
784
    }
785
786
    /**
787
     * Test for the updateRoleDraft() method.