Code Duplication    Length = 20-24 lines in 3 locations

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

@@ 310-333 (lines=24) @@
307
     * @see \eZ\Publish\API\Repository\RoleService::createRoleDraft()
308
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testNewRoleCreateStruct
309
     */
310
    public function testCreateRoleDraft()
311
    {
312
        $repository = $this->getRepository();
313
314
        /* BEGIN: Use Case */
315
316
        $roleService = $repository->getRoleService();
317
        $roleCreate = $roleService->newRoleCreateStruct('roleName');
318
319
        // @todo uncomment when support for multilingual names and descriptions is added EZP-24776
320
        // $roleCreate->mainLanguageCode = 'eng-US';
321
322
        $roleDraft = $roleService->createRole($roleCreate);
323
        $roleService->publishRoleDraft($roleDraft);
324
        $role = $roleService->loadRole($roleDraft->id);
325
        $newRoleDraft = $roleService->createRoleDraft($role);
326
327
        /* END: Use Case */
328
329
        $this->assertInstanceOf(
330
            '\\eZ\\Publish\\API\\Repository\\Values\\User\\RoleDraft',
331
            $newRoleDraft
332
        );
333
    }
334
335
    /**
336
     * Test for the createRole() method.
@@ 855-876 (lines=22) @@
852
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
853
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testUpdateRole
854
     */
855
    public function testUpdateRoleThrowsInvalidArgumentException()
856
    {
857
        $repository = $this->getRepository();
858
859
        /* BEGIN: Use Case */
860
        $roleService = $repository->getRoleService();
861
        $roleCreate = $roleService->newRoleCreateStruct('newRole');
862
863
        // @todo uncomment when support for multilingual names and descriptions is added EZP-24776
864
        // $roleCreate->mainLanguageCode = 'eng-US';
865
866
        $roleDraft = $roleService->createRole($roleCreate);
867
        $roleService->publishRoleDraft($roleDraft);
868
        $role = $roleService->loadRole($roleDraft->id);
869
870
        $roleUpdate = $roleService->newRoleUpdateStruct();
871
        $roleUpdate->identifier = 'Editor';
872
873
        // This call will fail with an InvalidArgumentException, because Editor is a predefined role
874
        $roleService->updateRole($role, $roleUpdate);
875
        /* END: Use Case */
876
    }
877
878
    /**
879
     * Test for the updateRoleDraft() method.
@@ 913-932 (lines=20) @@
910
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testCreateRole
911
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testLoadRoles
912
     */
913
    public function testDeleteRole()
914
    {
915
        $repository = $this->getRepository();
916
917
        /* BEGIN: Use Case */
918
        $roleService = $repository->getRoleService();
919
        $roleCreate = $roleService->newRoleCreateStruct('newRole');
920
921
        // @todo uncomment when support for multilingual names and descriptions is added EZP-24776
922
        // $roleCreate->mainLanguageCode = 'eng-US';
923
924
        $roleDraft = $roleService->createRole($roleCreate);
925
        $roleService->publishRoleDraft($roleDraft);
926
        $role = $roleService->loadRole($roleDraft->id);
927
928
        $roleService->deleteRole($role);
929
        /* END: Use Case */
930
931
        $this->assertEquals(5, count($roleService->loadRoles()));
932
    }
933
934
    /**
935
     * Test for the deleteRoleDraft() method.