Code Duplication    Length = 22-24 lines in 2 locations

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

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