Code Duplication    Length = 24-24 lines in 2 locations

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

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