Code Duplication    Length = 20-24 lines in 3 locations

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

@@ 216-239 (lines=24) @@
213
     * @see \eZ\Publish\API\Repository\RoleService::createRoleDraft()
214
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testNewRoleCreateStruct
215
     */
216
    public function testCreateRoleDraft()
217
    {
218
        $repository = $this->getRepository();
219
220
        /* BEGIN: Use Case */
221
222
        $roleService = $repository->getRoleService();
223
        $roleCreate = $roleService->newRoleCreateStruct('roleName');
224
225
        // @todo uncomment when support for multilingual names and descriptions is added EZP-24776
226
        // $roleCreate->mainLanguageCode = 'eng-US';
227
228
        $roleDraft = $roleService->createRole($roleCreate);
229
        $roleService->publishRoleDraft($roleDraft);
230
        $role = $roleService->loadRole($roleDraft->id);
231
        $newRoleDraft = $roleService->createRoleDraft($role);
232
233
        /* END: Use Case */
234
235
        $this->assertInstanceOf(
236
            '\\eZ\\Publish\\API\\Repository\\Values\\User\\RoleDraft',
237
            $newRoleDraft
238
        );
239
    }
240
241
    /**
242
     * Test for the createRole() method.
@@ 273-294 (lines=22) @@
270
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
271
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testCreateRoleDraft
272
     */
273
    public function testCreateRoleDraftThrowsInvalidArgumentException()
274
    {
275
        $repository = $this->getRepository();
276
277
        /* BEGIN: Use Case */
278
279
        $roleService = $repository->getRoleService();
280
        $roleCreate = $roleService->newRoleCreateStruct('Editor');
281
282
        // @todo uncomment when support for multilingual names and descriptions is added EZP-24776
283
        // $roleCreate->mainLanguageCode = 'eng-US';
284
285
        $roleDraft = $roleService->createRole($roleCreate);
286
        $roleService->publishRoleDraft($roleDraft);
287
        $role = $roleService->loadRole($roleDraft->id);
288
        $roleService->createRoleDraft($role); // First role draft
289
290
        // This call will fail with an InvalidArgumentException, because there is already a draft
291
        $roleService->createRoleDraft($role);
292
293
        /* END: Use Case */
294
    }
295
296
    /**
297
     * Test for the createRole() method.
@@ 821-840 (lines=20) @@
818
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testCreateRole
819
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testLoadRoles
820
     */
821
    public function testDeleteRole()
822
    {
823
        $repository = $this->getRepository();
824
825
        /* BEGIN: Use Case */
826
        $roleService = $repository->getRoleService();
827
        $roleCreate = $roleService->newRoleCreateStruct('newRole');
828
829
        // @todo uncomment when support for multilingual names and descriptions is added EZP-24776
830
        // $roleCreate->mainLanguageCode = 'eng-US';
831
832
        $roleDraft = $roleService->createRole($roleCreate);
833
        $roleService->publishRoleDraft($roleDraft);
834
        $role = $roleService->loadRole($roleDraft->id);
835
836
        $roleService->deleteRole($role);
837
        /* END: Use Case */
838
839
        $this->assertEquals(5, count($roleService->loadRoles()));
840
    }
841
842
    /**
843
     * Test for the deleteRoleDraft() method.