Code Duplication    Length = 29-34 lines in 3 locations

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

@@ 3519-3552 (lines=34) @@
3516
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup
3517
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup
3518
     */
3519
    public function testCreateContentTypeGroupInTransactionWithCommit()
3520
    {
3521
        $repository = $this->getRepository();
3522
3523
        /* BEGIN: Use Case */
3524
        $contentTypeService = $repository->getContentTypeService();
3525
3526
        // Get create struct and set language property
3527
        $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('new-group');
3528
        /* @todo uncomment when support for multilingual names and descriptions is added
3529
        $groupCreate->mainLanguageCode = 'eng-GB';
3530
        */
3531
3532
        // Start a new transaction
3533
        $repository->beginTransaction();
3534
3535
        try {
3536
            // Create the new content type group
3537
            $groupId = $contentTypeService->createContentTypeGroup($groupCreate)->id;
3538
3539
            // Rollback all changes
3540
            $repository->commit();
3541
        } catch (Exception $e) {
3542
            // Cleanup hanging transaction on error
3543
            $repository->rollback();
3544
            throw $e;
3545
        }
3546
3547
        // Load created content type group
3548
        $group = $contentTypeService->loadContentTypeGroup($groupId);
3549
        /* END: Use Case */
3550
3551
        $this->assertEquals($groupId, $group->id);
3552
    }
3553
3554
    /**
3555
     * Test for the updateContentTypeGroup() method.
@@ 3906-3936 (lines=31) @@
3903
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier
3904
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException
3905
     */
3906
    public function testCopyContentTypeInTransactionWithCommit()
3907
    {
3908
        $repository = $this->getRepository();
3909
3910
        /* BEGIN: Use Case */
3911
        $contentTypeService = $repository->getContentTypeService();
3912
3913
        // Load content type to copy
3914
        $contentType = $contentTypeService->loadContentTypeByIdentifier('comment');
3915
3916
        // Start a new transaction
3917
        $repository->beginTransaction();
3918
3919
        try {
3920
            // Complete copy of the content type
3921
            $contentTypeId = $contentTypeService->copyContentType($contentType)->id;
3922
3923
            // Commit all changes
3924
            $repository->commit();
3925
        } catch (Exception $e) {
3926
            // Cleanup hanging transaction on error
3927
            $repository->rollback();
3928
            throw $e;
3929
        }
3930
3931
        // Load the new content type copy.
3932
        $copiedContentType = $contentTypeService->loadContentType($contentTypeId);
3933
        /* END: Use Case */
3934
3935
        $this->assertEquals($contentTypeId, $copiedContentType->id);
3936
    }
3937
3938
    /**
3939
     * Test for the deleteContentType() method.

eZ/Publish/API/Repository/Tests/ContentServiceTest.php 1 location

@@ 4373-4401 (lines=29) @@
4370
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately
4371
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException
4372
     */
4373
    public function testCreateContentWithLocationCreateParameterInTransactionWithCommit()
4374
    {
4375
        $repository = $this->getRepository();
4376
4377
        $contentService = $repository->getContentService();
4378
4379
        /* BEGIN: Use Case */
4380
        // Start a transaction
4381
        $repository->beginTransaction();
4382
4383
        try {
4384
            $draft = $this->createContentDraftVersion1();
4385
4386
            $contentId = $draft->id;
4387
4388
            // Roleback the transaction
4389
            $repository->commit();
4390
        } catch (Exception $e) {
4391
            // Cleanup hanging transaction on error
4392
            $repository->rollback();
4393
            throw $e;
4394
        }
4395
4396
        // Load the new content object
4397
        $content = $contentService->loadContent($contentId);
4398
        /* END: Use Case */
4399
4400
        $this->assertEquals($contentId, $content->id);
4401
    }
4402
4403
    /**
4404
     * Test for the createContentDraft() method.