Code Duplication    Length = 24-24 lines in 2 locations

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

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