Code Duplication    Length = 24-24 lines in 2 locations

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

@@ 327-350 (lines=24) @@
324
     * @see \eZ\Publish\API\Repository\RoleService::createRoleDraft()
325
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testNewRoleCreateStruct
326
     */
327
    public function testCreateRoleDraft()
328
    {
329
        $repository = $this->getRepository();
330
331
        /* BEGIN: Use Case */
332
333
        $roleService = $repository->getRoleService();
334
        $roleCreate = $roleService->newRoleCreateStruct('roleName');
335
336
        // @todo uncomment when support for multilingual names and descriptions is added EZP-24776
337
        // $roleCreate->mainLanguageCode = 'eng-US';
338
339
        $roleDraft = $roleService->createRole($roleCreate);
340
        $roleService->publishRoleDraft($roleDraft);
341
        $role = $roleService->loadRole($roleDraft->id);
342
        $newRoleDraft = $roleService->createRoleDraft($role);
343
344
        /* END: Use Case */
345
346
        $this->assertInstanceOf(
347
            '\\eZ\\Publish\\API\\Repository\\Values\\User\\RoleDraft',
348
            $newRoleDraft
349
        );
350
    }
351
352
    /**
353
     * Test for the createRole() method.
@@ 384-407 (lines=24) @@
381
     * @see \eZ\Publish\API\Repository\RoleService::createRoleDraft()
382
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testCreateRoleDraft
383
     */
384
    public function testCreateRoleDraftThrowsInvalidArgumentException()
385
    {
386
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\InvalidArgumentException::class);
387
388
        $repository = $this->getRepository();
389
390
        /* BEGIN: Use Case */
391
392
        $roleService = $repository->getRoleService();
393
        $roleCreate = $roleService->newRoleCreateStruct('Editor');
394
395
        // @todo uncomment when support for multilingual names and descriptions is added EZP-24776
396
        // $roleCreate->mainLanguageCode = 'eng-US';
397
398
        $roleDraft = $roleService->createRole($roleCreate);
399
        $roleService->publishRoleDraft($roleDraft);
400
        $role = $roleService->loadRole($roleDraft->id);
401
        $roleService->createRoleDraft($role); // First role draft
402
403
        // This call will fail with an InvalidArgumentException, because there is already a draft
404
        $roleService->createRoleDraft($role);
405
406
        /* END: Use Case */
407
    }
408
409
    /**
410
     * Test for the createRole() method.